<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="main-body" class="main-body-patrol">
    <div class="head-content">
        <div class="form-inline">
            <div class="head-right-div">
                <input id="state" type="hidden" value="2" />
                <input id="hdServerDate" type="hidden" value="" />
                <input id="hdInpatientDate" type="hidden" value="" /> 计划执行日期：
                <input type="text" id="startTime" name="startTime" class="form-control date" style="padding: 2px 4px;width: 122px !important;height: 32px" />
                ~ <input type="text" id="endTime" name="endTime" class="form-control date" style="padding: 2px 4px;width: 122px !important;height: 32px" />&emsp;
            </div>

            <div class="head-right-div" id="orderTypeDiv">
                医嘱分类：
                <select class="form-control" name="orderType" id="orderType" style="width:80px;height:32px;border: 1px solid #dcdcdc;">
                    <option value="1">药品</option>
                    <option value="2">诊疗</option>
                    <option value="4">检验</option>
                    <option value="0">输血记录</option>
                </select>
            </div>
            <div class="head-right-div hide" id="standingDiv">
                <select class="form-control" name="standing" id="standing" style="width:66px;height:32px;border: 1px solid #dcdcdc;">
                    <option value="all">全部</option>
                    <option value="1">长期</option>
                    <option value="0">临时</option>
                </select>
            </div>
            <div class="head-right-div " id="istom">
                <input type="checkbox"  name="cb_istom" id="cb_istom" value="1"> 选中查找明日预执行医嘱
            </div>

            <div class="head-right-div hide" id="medicineDiv">
                <select class="form-control" name="medicine" id="medicine" style="width:66px;height:32px;border: 1px solid #dcdcdc;">
                    <option value="all">全部</option>
                    <option value="jd">大量</option>
                    <option value="zs">小量</option>
                    <option value="kfy">口服药</option>
                    <option value="gs">管饲</option>
                </select>
            </div>
            <div class="head-right-div " id="geiyaoDiv" style="display:none;">
                <select id="geiyaoWays" name="geiyaoWays" class="form-control half editable-select form-control" data-relate="geiyaoWays" tabindex="104">
                </select>
            </div>

            <div class="head-right-div hide" id="performStatusDiv">
                执行状态：
                <select class="form-control" name="performStatus" id="performStatus" style="width:80px;height:34px;border: 1px solid #ccc;">
                    <option value="">全部</option>
                    <option value="0">未执行</option>
                    <option value="1">执行中</option>
                    <option value="2">已执行</option>
                </select>
            </div>
            <div class="head-right-div hide" id="sampleStatusDiv">
                检验状态：
                <select class="form-control" name="sampleStatus" id="sampleStatus" style="width:80px;height:34px;border: 1px solid #ccc;">
                    <option value="">全部</option>
                    <option value="0">未采集</option>
                    <option value="1">已采集</option>
                    <option value="2">已送检</option>
                    <option value="3">已接收</option>
                </select>
            </div>
            <div class="head-right-div hide" id="bloodStatusDiv">
                输血状态：
                <select class="form-control" name="bloodStatus" id="bloodStatus" style="width:80px;height:34px;border: 1px solid #ccc;">
                    <option value="">全部</option>
                    <option value="1">未接收</option>
                    <option value="2">血袋出库</option>
                    <option value="3">已接收</option>
                    <option value="4">输血开始</option>
                    <option value="5">输注结束</option>
                    <option value="6">血袋回收</option>
                    <option value="7">退回</option>
                </select>
            </div>
            <div class="head-right-div hide" id="pathologyStatusDiv">
                病理状态：
                <select class="form-control" name="pathologyStatus" id="pathologyStatus" style="width:80px;height:34px;border: 1px solid #ccc;">
                    <option value="">全部</option>
                    <option value="1">未采集</option>
                    <option value="2">已采集</option>
                    <option value="3">已送检</option>
                    <option value="4">已接收</option>
                    <option value="5">已报告</option>
                </select>
            </div>


            <div class="head-right-div" id="geiyaosDiv">
                <label for="geiyaoWayslist">&emsp;给药方式：</label>
                <input style="width: 300px; height: 34px; border-radius: 4px; outline-style: none; border: 0; border: 1px solid #aaa;" name="geiyaoWayslist" id="geiyaoWayslist" data-relate="geiyaoWayslist" aria-invalid="false" >
                <div style="display:none;width: 500px; height: 200px; position: absolute; left: 135px; bottom: 49px; z-index: 20; background: rgb(255, 255, 255); border: 1px solid rgb(204, 204, 204); " id="mutipleDiv">
                    <ul style="width: 100%; padding-left: 10px; overflow-y: auto; height: 160px;"></ul>
                    <div style="border-top: 1px solid #ccc; height: 34px; margin-top: -4px; line-height: 34px;">
                        <span class="default-button" id="default-save">确定</span><span class="default-button" id="default-chooseAll">全选</span><span class="default-button" id="default-reset">重置</span>
                    </div>
                </div>
            </div>


            <div class="head-right-div" id="head-right-div-btn" style="width:400px;margin-left: 10px;">
                <button type="button" class="btn-emr btn-emr-default patrol-btn btn-emr-green" id="btnQuery">查询</button>&nbsp;
                <button id="btnPrint" type="button" class="btn-emr btn-emr-default patrol-btn">打印</button>&nbsp;
                <button id="btnPrint2" type="button" class="btn-emr btn-emr-default patrol-btn " >打印明天医嘱</button>&nbsp;
                <button id="btnExport" type="button" class="btn-emr btn-emr-default patrol-btn"> 导出</button>&nbsp;
                <button id="btnAllExport" type="button" class="btn-emr btn-emr-default patrol-btn hide"> 全部导出</button>&nbsp;
                <button id="btnBatch" type="button" class="btn-emr btn-emr-default patrol-btn hide">批量处理</button>
            </div>
        </div>
        <div class="head-right-div" style="float: right; width: 350px;">
            <label for="sel_ward">病区：</label>
            <select class="form-control" name="sel_ward" id="sel_ward" style="width: auto;display: inline-block">
            </select>
        </div>
    </div>
    <div id="left-content">
        <div class="input-group">
            <input id="patient-filter" type="text" class="form-control search-input" placeholder="请输入床号或姓名" aria-describedby="search-btn" />
            <span class="input-group-btn" id="search-btn"><span class="search"><img class="search-img" alt="查询" src="/img/inpatient-search.png" /></span></span></div>
        <div class="show patient-type">
            <span>病人分类：</span><span>
                <select id="selectGroup" name="D1" class="btn btn-default dropdown-toggle" style="padding: 6px 10px;">
                    <option value="">整个病区</option>
                </select>
            </span>
        </div>
        <div class="patient-list">
            <div id="totalPatient">
                <span></span>
            </div>
            <div class="patient-list-header clearfix">
                <span><input type="checkbox" class="magic-checkbox" name="allpatient" id="allPatient" /><label for="allPatient" class="allPatient"></label></span>
                <span>床号</span>
                <span>姓名</span>
            </div>
            <div style="height: 85.5%">
                <div id="patientList" style="height:85%">
                    <table class="table" id="patientTable" style="margin-bottom: 0">
                    </table>
                    <div class="patient-index-not-found" style="display: none;">
                        <span style="color: rgb(170, 170, 170);width:150px;">未查询到患者！</span>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="right-content">
        <div id="advice-content" class="printTable" style="height:100%;">
            <!-- <div th:include="component::printHead" class="printHead printText" ></div> -->
            <div id="waiting" style="text-align:center;margin-top:100px;"><img alt="" src="/img/waiting2.gif" />&nbsp;正在加载数据，请稍后...</div>
            <div id="gridList"></div>
        </div>
        <div id="advice-test-content" class="printTable hide" style="height:100%;">
            <!-- <div th:include="component::printHead" class="printHead printText" ></div> -->
            <div id="gridTestList"></div>
        </div>
        <div id="advice-transfusion-content" class="printTable hide" style="height:100%;">
            <!-- 	<div th:include="component::printHead" class="printHead printText" ></div> -->
            <div id="gridTransfusionList"></div>
        </div>
    </div>
</div>
<span id="num" class="hide"></span>
</body>
<script src="/component/jQuery/jQuery-2.1.4.min.js"></script>
<script src="/js/LodopFuncs.js"></script>
<script src="/component/fixedheadertable/jsgrid.min.js"></script>
<script src="/component/slimScroll/jquery.slimscroll.js"></script>
<script src="/component/layer/layer.js"></script>
<script src="/component/datepicker/WdatePicker.js"></script>
<script src="/js/common.js"></script>
<script src="/component/admin/js/elec.js"></script>
<script>
    $('#patientList').slimScroll({
        size: '5px',
        railVisible: false,
        alwaysVisible: true,
        height: '100%',
        opacity: 0.2,
    });
    $.ajaxSetup({
        complete: function (res) { }
    })
    ; (function ($) {
        $(document).attr("title", "住院巡视卡");
        addToken();
        var argUrl = getRequestUrl();
        var Page = {};
        var order_type = "";
        var wardId = cache.get("wardId");
        var indexId = 0;
        var startOldTime = "";
        var endOldTime = "";
        var isshowstanding = "";//是否显示长期来说医嘱设施条件
        var isshowgeiyao = "";//是否显示给药方式
        var isshowbl = "";//是否显示病理
        var isshowds = "";//巡视卡显示滴速
        var pathologyNum = "6";//病理
        var gy;
        if (null != wardId && wardId.length > 0) {
            //读取cache设置病区切换
            if (wardId != $("#sel_ward").val()) {
                $("#sel_ward option[value='" + wardId + "']").attr('selected', 'selected');
            }
        }
        Page.Event = {
            init: function () {
                this.initPatientInfo();
                this.initDatepicker();
                this.patientInit();
                this.getData();
                this.queryList();
                this.changeWard();
                this.initWard();
                this.getPatientsCount();
                this.typeSelect();
                this.print();
                this.print2();
                this.getAllWardGroup();
                this.changeGroup();
                this.changeexecutionStatus();
                this.exportExcel();
                this.ingoway();
                this.inittom();

            },
            inittom: function () {

                var nowday1 = new Date().Format("yyyy-MM-dd 00:00");

                var day2 = new Date();
                day2.setTime(day2.getTime() + 24 * 60 * 60 * 1000);
                var nowday2 = day2.Format("yyyy-MM-dd 00:00");

                var day3 = new Date();
                day3.setTime(day3.getTime() + 24 * 60 * 60 * 1000 * 2);
                var nowday3 = day3.Format("yyyy-MM-dd 00:00");

                $("#cb_istom").on('click', function () {
                    if ($(this).prop("checked")) {
                        layer.alert("选中查找预执行医嘱，查询时间会自动改为明日，请注意!");
                        $('#startTime').val(nowday2);
                        $("#endTime").val(nowday3);
                    }
                    $("#btnQuery").trigger("click");

                });

            },
            initPatientInfo: function () {
                var objUrl = getRequestUrl();
                var _args = {
                    inpatientId: objUrl.inpatientId
                };
                $.ajax({
                    url: '/template/patrolcard/getPageInfo',
                    type: 'GET',
                    async: false,
                    contentType: "application/json;charset=utf-8",
                    data: _args,
                }).done(function (data) {
                    var wards = data.results.result.wards;
                    $("#state").val(data.results.state);
                    $("#hdServerDate").val(data.results.startTime);
                    $("#hdInpatientDate").val(data.results.endTime);
                    //if(data.results.hideGroup&&data.results.hideGroup=='1'){
                    //  $("#patientGroup").attr("class","hide");
                    //}else{
                    //  $("#patientGroup").attr("class","show patient-type");
                    //}
                    if (wards) {
                        var html = "";
                        for (var i = 0; i < wards.length; i++) {
                            html += "<option value=" + wards[i].deptWardId + ">" + wards[i].wardName + "</option>";
                        }
                        $("#sel_ward").html(html);
                    }
                    //$("#sel_ward option:first").prop("selected", 'selected');
                    $("#num").html(data.results.num);

                    //给药方式
                    gy = getCommonDic({ "type": "geiyaoWays", "version": "1" });
                    var shtml = "";
                    $("#geiyaoWays").html("");
                    $.each(gy.geiyaoWays, function (i, n) {
                        $("#geiyaoWays").append('<option value="' + n.code + '">' + n.value + '</option>');
                    });

                }).fail(function (xhr) {
                    console.log(xhr);
                });
            },
            exportExcel: function () {
                //勾选导出
                $("#head-right-div-btn").on("click", "#btnExport", function () {
                    var wardName = $("#sel_ward").find('option:selected').text();
                    var strStartTime = $('#startTime').val();
                    var strEndTime = $('#endTime').val();
                    var _startTime = new Date(strStartTime).Format("yyyy-MM-dd hh:mm:00");
                    var _endTime = new Date(strEndTime).Format("yyyy-MM-dd hh:mm:59");
                    var inpatientIds = new Array();
                    $.each($('#patientTable tbody tr:visible input[name="patient"]:checked'), function () {
                        inpatientIds.push($(this).val());
                    });
                    //个人页是没有勾选导出的
                    if (inpatientIds.length < 1) {
                        if (isNotEmpty($("#inpatientId").val())) {
                            inpatientIds.push($("#inpatientId").val());
                        }
                        if (isNotEmpty(getInpatientId())) {
                            inpatientIds.push(getInpatientId());
                        }
                    }
                    var performStatus = $("#performStatus").val();
                    var sampleStatus = $("#sampleStatus").val();
                    var bloodStatus = $("#bloodStatus").val();
                    var medicineType = $('#medicine').val();
                    var href = "/patrolcard/exportExcel?orderType=" + order_type + "&wardName=" + wardName + "&startTime=" + _startTime + "&endTime=" + _endTime + "&inpatientIds=" + JSON.stringify(inpatientIds) + "&performStatus=" + performStatus + "&sampleStatus=" + sampleStatus + "&bloodStatus=" + bloodStatus + "&medicineType=" + medicineType;
                    window.open(href);
                });
                //全部导出
                $("#head-right-div-btn").on("click", "#btnAllExport", function () {
                    var wardName = $("#sel_ward").find('option:selected').text();
                    var strStartTime = $('#startTime').val();
                    var strEndTime = $('#endTime').val();
                    var _startTime = new Date(strStartTime).Format("yyyy-MM-dd hh:mm:00");
                    var _endTime = new Date(strEndTime).Format("yyyy-MM-dd hh:mm:59");
                    var performStatus = $("#performStatus").val();
                    var sampleStatus = $("#sampleStatus").val();
                    var bloodStatus = $("#bloodStatus").val();
                    var medicineType = $('#medicine').val();
                    var state = $('#state').val();
                    var wardCode = $('#sel_ward').val();
                    var href = "/patrolcard/exportExcel?orderType=" + order_type + "&wardName=" + wardName + "&state=" + state + "&ward_code=" + wardCode + "&startTime=" + _startTime + "&endTime=" + _endTime + "&performStatus=" + performStatus + "&sampleStatus=" + sampleStatus + "&bloodStatus=" + bloodStatus + "&medicineType=" + medicineType;
                    window.open(href);
                })
            },

            //日期范围
            initDatepicker: function () {
                var startTime = $("#hdServerDate").val();
                var endTime = $("#hdInpatientDate").val();
                var outTime = getOutTime("yyyy-MM-dd hh:mm");
                var state = $('#state').val();
                if (state == "3") {
                    $("#btnAllExport").removeClass("hide");
                }

                $("#endTime").on('click', function () {
                    if (isNotEmpty(outTime))
                        if (state == "3") {
                            WdatePicker({
                                dateFmt: 'yyyy-MM-dd HH:mm', maxDate: outTime, isShowClear: false, onpicked: function () {
                                    Page.Event.patientInit();
                                    Page.Event.getPatientsCount();
                                }
                            });
                        } else {
                            WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm', maxDate: outTime, isShowClear: false });
                        }
                    else
                    if (state == "3") {
                        WdatePicker({
                            dateFmt: 'yyyy-MM-dd HH:mm', isShowClear: false, onpicked: function () {
                                Page.Event.patientInit();
                                Page.Event.getPatientsCount();
                            }
                        });
                    } else {
                        WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm', isShowClear: false });
                    }
                });
                $('#startTime').on('click', function () {
                    if (state == "3") {
                        WdatePicker({
                            dateFmt: 'yyyy-MM-dd HH:mm', maxDate: '#F{$dp.$D(\'endTime\')}', isShowClear: false, onpicked: function (dp) {
                                Page.Event.patientInit();
                                Page.Event.getPatientsCount();
                            }
                        });
                    } else {
                        WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm', isShowClear: false });
                    }
                });

                $('#startTime').on('blur', function () {
                    if (state == "3") {
                        Page.Event.patientInit();
                        Page.Event.getPatientsCount();
                    }
                });
                $("#endTime").on('blur', function () {
                    if (state == "3") {
                        Page.Event.patientInit();
                        Page.Event.getPatientsCount();
                    }
                });
                if (isNotEmpty(outTime) && new Date(outTime).getTime() < new Date(endTime).getTime()) {
                    $('#startTime').val(new Date(outTime).Format("yyyy-MM-dd 00:00"));
                    $("#endTime").val(new Date(addDate(outTime, 1)).Format("yyyy-MM-dd 00:00"));
                    endOldTime = $("#endTime").val();
                    startOldTime = $("#endTime").val();
                } else {
                    $('#startTime').val(new Date(startTime).Format("yyyy-MM-dd 00:00"));
                    $("#endTime").val(new Date(endTime).Format("yyyy-MM-dd 00:00"));
                    endOldTime = $("#endTime").val();
                    startOldTime = $("#endTime").val();
                }
            },
            //病人列表
            patientInit: function (obj) {
                isshowstanding = isOpenRole({ parameterName: '巡视卡显示长期临时分类' });
                isshowgeiyao = isOpenRole({ parameterName: '巡视卡给药方式' });
                isshowbl = isOpenRole({ parameterName: '巡视卡显示病理' });
                isshowds = isOpenRole({ parameterName: '巡视卡显示输液滴速' });

                var length = $('.patient-list').length;
                if ($('.patient-list').length > 0) {
                    this.getlist(obj);
                }
                return this;
            },

            getlist: function (obj) {
                var that = this;
                var wardCode = $('#sel_ward').val();
                var state = $('#state').val();
                var startTime = $('#startTime').val();
                var endTime = $('#endTime').val();
                var _args = {
                    ward_code: wardCode,
                    state: state
                };
                if (state == '3') {
                    _args.startTime = startTime;
                    _args.endTime = endTime;

                    var time_diff = new Date(endTime) - new Date(startTime);
                    var days = Math.floor(time_diff / (24 * 3600 * 1000));
                    if (days > 31) {
                        layer.alert("时间范围只能选择一个月！");
                        $('#startTime').val(startOldTime);
                        $('#endTime').val(endOldTime);
                        return;
                    } else {
                        startOldTime = $('#startTime').val();
                        endOldTime = $('#endTime').val();
                    }
                }
                if (obj) {
                    _args = $.extend({}, _args, obj);
                }
                $.ajax({
                    url: "/selectPatientListByState",
                    type: "GET",
                    async: false,
                    contentType: "application/json;charset=utf-8",
                    data: _args
                })
                    .done(function (result) {
                        if (result.state == 200) {
                            if (!isEmptyObject(result.results)) {
                                if (!isEmptyObject(result.results.inpatients)) {
                                    that.initHtml(result.results);
                                } else {
                                    $('#patientTable').empty();
                                    patientSearchedDisplay();
                                }
                            }
                        } else {
                            console.log(result.msg);
                        }
                    })
                    .fail(function () {
                        console.log(result.msg);
                    });
            },
            initHtml: function (data) {
                var inpatients = data.inpatients;
                var htmlArr = [];
                var i = 0;
                for (; i < inpatients.length; i++) {
                    var html = '<tr><td><input type="checkbox" class="magic-checkbox" name="patient" id="' + inpatients[i].inpatientId + '" value="' + inpatients[i].inpatientId + '"/><label for="' + inpatients[i].inpatientId + '">&nbsp;</label></td><td class="patient-bedNum">' + inpatients[i].bedNum + '</td><td class="patient-name">' + inpatients[i].inpatientName + '</td></tr>';
                    htmlArr.push(html);
                }
                this.inpatientListArr = htmlArr;
                $('#patientTable').html(htmlArr.join(''));
                patientSearchedDisplay();
                // var state = $("#state").val();
                // if(state == "3"){//出院病人全选按钮禁用
                //     $('input[name="allpatient"]').prop('disabled',true);
                // }
            },

            //查询医嘱
            queryList: function () {
                $("#btnQuery").click(function () {
                    Page.Event.getData();
                });
            },
            //加载巡视卡数据
            getData: function () {

                if (isshowbl == "1") {
                    var v = 0;
                    $.each($("#orderType option"), function (i, n) {
                        if ($(n).text() == "病理") {
                            v++;
                        }
                    })
                    if (v == 0) {
                        $("#orderType").append("<option value=\"" + pathologyNum + "\" >病理</option>");
                    }
                }

                var strStartTime = $('#startTime').val();
                var strEndTime = $('#endTime').val();
                var state = $("#state").val();
                if (state == "3") {//出院病人全选按钮禁用
                    var time_diff = new Date(strEndTime) - new Date(strStartTime);
                    var days = Math.floor(time_diff / (24 * 3600 * 1000));
                    if (days > 31) {
                        layer.alert("时间范围只能选择一个月！");
                        $('#startTime').val(startOldTime);
                        $('#endTime').val(endOldTime);
                        return;
                    } else {
                        startOldTime = $('#startTime').val();
                        endOldTime = $('#endTime').val();
                    }
                }
                var _startTime = new Date(strStartTime).Format("yyyy-MM-dd hh:mm:00");
                var _endTime = new Date(strEndTime).Format("yyyy-MM-dd hh:mm:59");
                var wardCode = $('#sel_ward').val();
                var num = $('#num').text();
                var showType = $('#showType').text();
                var medicineType = $('#medicine').val();
                var geiyaoType = $('#geiyaoWays').val();                     //给药方式
                var patientNum = $("#patientNum").text();
                var entryTime = $("#hdEntryTime").val();
                var inpatientIds = new Array();
                var supplyCode = new Array();
                order_type = $('#orderType').val();
                var entryType = undefined;
                if (order_type == "0") {
                    entryType = $('#entryType').val();
                }
                var performStatus = $("#performStatus").val();
                var sampleStatus = $("#sampleStatus").val();
                var bloodStatus = $("#bloodStatus").val();
                var standingType = $("#standing").val();
                var pathologyStatus = $("#pathologyStatus").val();





                var _args = {
                    startTime: _startTime,
                    endTime: _endTime,
                    orderType: order_type,
                    performStatus: performStatus,
                    sampleStatus: sampleStatus,
                    bloodStatus: bloodStatus,
                    pathologyStatus: pathologyStatus,
                    showType: showType,
                    entryType: entryType,
                    patientNum: patientNum,
                    entryTime: entryTime,
                    standing: standingType,
                    geiyaoWay: geiyaoType
                };
                if ('1' == num) {
                    _args = {
                        startTime: _startTime,
                        endTime: _endTime,
                        orderType: order_type,
                        performStatus: performStatus,
                        sampleStatus: sampleStatus,
                        bloodStatus: bloodStatus,
                        pathologyStatus: pathologyStatus,
                        num: 1
                    }
                }


                if (order_type == "2") {
                    var obj = {
                        orderCategory: "5",
                    };
                    _args = $.extend({}, _args, obj);
                }

                if ($('#pageFlag').val() == 'performOperate') {
                    var inpatientId = getInpatientId();
                    if (!isNotEmpty(inpatientId)) {
                        inpatientId = $("#inpatientId").val();
                    }
                    inpatientIds.push(inpatientId);
                    var obj = {
                        inpatientIds: JSON.stringify(inpatientIds),
                    };
                    _args = $.extend({}, _args, obj);
                } else {
                    $.each($('#patientTable tbody tr:visible input[name="patient"]:checked'), function () {
                        inpatientIds.push($(this).val());
                    });
                    if (inpatientIds.length != 0) {
                        var obj = {
                            inpatientIds: JSON.stringify(inpatientIds),
                        };
                        _args = $.extend({}, _args, obj);
                    }
                }

                //隐藏线索长期临时
                if ((isshowstanding == "true" || isshowstanding == "1") && order_type == "1") {
                    $("#standingDiv").show();
                    $("#standingDiv").removeClass("hide");
                } else {
                    $("#standingDiv").hide();
                    $("#standingDiv").addClass("hide");
                    $("#standing").val("all");
                }
                //隐藏显示给药方式明细
                /*             if((isshowgeiyao=="true"||isshowgeiyao=="1") && order_type=="1"){
                                var g=getCommonDic({"type":"geiyaoWays","version":"1"});
                                var shtml="";
                                $("#geiyaoWays").html("");
                                $.each(g.geiyaoWays,function(i,n){
                                    $("#geiyaoWays").append('<option value="'+n.code+'">'+n.value+'</option>');
                                });

                                console.log(g);
                                $("#geiyaoDiv").show();
                                $("#geiyaoDiv").removeClass("hide");
                                $("#medicineDiv").addClass("hide");
                                $('#medicine').val('all');
                            }else{
                                $("#geiyaoDiv").hide();
                                $("#geiyaoDiv").addClass("hide");
                                $("#geiyaoWays").val("all");
                            } */

                if (typeof (medicineType) != "undefined" && order_type == "1") {
                    var obj = {
                        medicineType: medicineType,
                    };
                    _args = $.extend({}, _args, obj);
                }

                if (argUrl.orderflag != undefined) {
                    _args = $.extend({}, _args, { orderflag: argUrl.orderflag });

                }
                if (order_type == pathologyNum) {
                    _args = $.extend({}, _args, { emergency: "all" });
                }

                //多选给药方式
                var gyfslist = new Array();
                $('#mutipleDiv ul input:checkbox:checked').each(function () {
                    gyfslist.push($(this).val());//向数组中添加元素
                });
                if (gyfslist.length > 0) { _args = $.extend({}, _args, { supplyCodes: gyfslist }); }
                //根据与预执行计划查找医嘱
                if ($("#cb_istom").prop("checked")) {
                    _args = $.extend({}, _args, { judgeFlag: "tom" });
                }



                $.ajax({
                    url: '/patrolcard/list',
                    type: 'POST',
                    contentType: 'application/json;charset=utf-8',
                    data: JSON.stringify(_args),
                    beforeSend: function () {
                        $("#gridList").empty();

                        $("#waiting").show();
                    },
                    complete: function () {
                        $("#waiting").hide();
                        //canDragTable();
                        resizeTableWidth();
                    }
                }).done(function (res) {
                    var result = JSON.parse(res).result;

                    if (result != "") {
                        //输血隔行增长
                        if (order_type == "0" || order_type == pathologyNum) {
                            var index = 0;
                            result.forEach(function (ele, i) {
                                if ((i + 1) % 2 != 0) {
                                    index += 1;
                                    ele.rowIndex = index;
                                }
                            });
                        } else {
                            result.forEach(function (ele, i) {
                                ele.rowIndex = i + 1;
                            });
                        }
                        //计划执行时间强行换行
                        if (order_type == "4") {
                            result.forEach(function (ele, i) {
                                var arr = ele.scheduleSamplingTime.split(" ");
                                arr.splice(1, 0, "<br/>");
                                var str = arr.join(" ");
                                ele.scheduleSamplingTime = str;
                            });
                        }
                    }
                    if (order_type == "4") {//检验类型
                        $("#gridList").jsGrid({
                            height: "100%",
                            width: "100%",
                            sorting: false,
                            paging: false,
                            search: false,
                            rowRenderer: null,
                            fields: [
                                { name: "orderId", width: 0, title: '', css: "hide cssorderId" },
                                { name: "sampleId", width: 0, title: '', css: "hide csssampleId" },
                                { name: "samplerId", width: 0, title: '', css: "hide csssamplerId" },
                                { name: "senderId", width: 0, title: '', css: "hide csssenderId" },
                                { name: "inpatientId", width: 0, title: '', css: "hide cssinpatientId" },
                                { name: "hisOrderIds", width: 0, title: '', css: "hide csshisOrderIds" },
                                { name: "rowIndex", type: "text", width: 28, title: '', css: "cssrowIndex" },
                                { name: "bedNum", type: "text", width: 45, title: '床号', css: "cssbedNum" },
                                { name: "name", type: "text", width: 57, title: '姓名', css: 'print-name name' },
                                { name: "sampleId", type: "text", width: 94, title: '检验条码', css: "csssampleId2" },
                                {
                                    itemTemplate: function (value, item) {
                                        return $('<span>').text(item.emergency);
                                    },
                                    title: "急诊",
                                    align: "center",
                                    width: 35,
                                    css: "test-danger",
                                },
                                { name: "orderName", type: "text", width: 175, title: '检验项目', css: 'ordername' },
                                { name: "doctor", type: "text", width: 62, title: '申请人' },
                                { name: "makeTime", type: "text", width: 76, title: '申请时间', css: 'blood-time' },
                                { name: "scheduleSamplingTime", type: "text", width: 85, title: '计划执行时间', css: 'blood-time' },
                                { name: "sampler", type: "text", width: 64, title: '采样人' },
                                { name: "samplingTime", type: "text", width: 76, title: '采样时间', css: 'blood-time' },
                                { name: "sender", type: "text", width: 64, title: '送检人' },
                                { name: "sendOperater", type: "text", width: 64, title: '核对人', css: "hide" },
                                { name: "sendTime", type: "text", width: 76, title: '送检时间', css: 'blood-time' },
                                { name: "reciver", type: "text", width: 64, title: '接收人' },
                                { name: "reciveTime", type: "text", width: 76, title: '接收时间', css: 'blood-time' },
                                { name: "status", type: "text", width: 55, title: '状态' },
                                {
                                    itemTemplate: function (value, item) {
                                        if (item.status == "3") {
                                            return "是";
                                        } else {
                                            return "否";
                                        }
                                    }, type: "text", width: 81, title: '是否出报告'
                                },
                                { name: "performMemo", type: "text", width: 75, title: '备注', css: 'cssperformMemo' },
                                { name: "sendOperaterId", width: 0, title: '', css: "hide", css: 'csssendOperaterId' }, //追加
                                {
                                    itemTemplate: function (_, item) {
                                        return $("<a>").text("异常处理").on("click", function () {
                                            indexId++;
                                            $(this).parent().parent().attr('id', 'index' + indexId);
                                            $(this).parent().parent().addClass('blue').siblings().removeClass('blue');
                                            Page.Event.openTestPage(this, 'index' + indexId);
                                        });
                                    },
                                    title: '操作',
                                    align: "center",
                                    width: 80,
                                    css: "exception"
                                },
                            ],
                            data: result
                        });
                        $('.test-danger span').each(function () {
                            if ($(this).text() == "急") {
                                $(this).addClass('isDanger');
                            } else {
                                $(this).removeClass('isDanger')
                            }
                        })
                    }
                    else if (order_type == "0") {//输血记录
                        $("#gridList").empty();
                        $("#gridList").jsGrid({
                            height: "100%",
                            width: "100%",
                            sorting: false,
                            paging: false,
                            search: false,
                            rowRenderer: function (item) {
                                var str = "";
                                if (item.flag == "flag") {
                                    var string = '<div id="step">' +
                                        '<ul>' +
                                        '<li><ul class="main_content ' + (item.sampler != '' && item.sampler != undefined ? 'current' : '') + '"><li>标本采集</li><li class="content_mid"><div class="circle">1</div></li><li>' + (item.samplingTime == undefined ? '' : item.samplingTime) + '</li> <li>' + (item.sampler == undefined ? '' : item.sampler) + '</li></ul></li>' +
                                        '<li><ul class="main_content ' + (item.sender != '' && item.sender != undefined ? 'current' : '') + '"><li>标本送检</li><li class="content_mid"><div class="line"></div><div class="circle">2</div></li><li>' + ((item.sendTime == undefined || item.sendTime == '') ? '' : item.sendTime) + '</li> <li>' + ((item.sender == '' || item.sender == undefined) ? ((item.sendOperater == '' || item.sendOperater == undefined) ? '' : item.sendOperater) : ((item.sendOperater == '' || item.sendOperater == undefined) ? item.sender : item.sender + '/' + item.sendOperater)) + '</li></ul></li>' +
                                        '<li><ul class="main_content ' + (item.reciver != '' && item.reciver != undefined ? 'current' : '') + '"><li>标本接收</li><li class="content_mid"><div class="line"></div><div class="circle">3</div></li><li>' + (item.reciveTime == undefined ? '' : item.reciveTime) + '</li> <li>' + (item.reciver == undefined ? '' : item.reciver) + '</li></ul></li>' +
                                        '<li><ul class="main_content ' + (item.outOperator != '' && item.outOperator != undefined ? 'current' : '') + '"><li>血袋出库</li><li class="content_mid"><div class="line"></div><div class="circle">4</div></li><li>' + (item.outTime == undefined ? '' : item.outTime) + '</li> <li>' + (item.outOperator == undefined ? '' : item.outOperator) + '</li></ul></li>' +
                                        '<li><ul class="main_content ' + (item.bloodReciver != '' && item.bloodReciver != undefined ? 'current' : '') + '"><li>血袋接收</li><li class="content_mid"><div class="line"></div><div class="circle">5</div></li><li>' + (item.bloodReciveTime == undefined ? '' : item.bloodReciveTime) + '</li> <li>' + (item.bloodReciver == undefined ? '' : item.bloodReciver) + '</li></ul></li>' +
                                        '<li><ul class="main_content ' + (item.performer != '' && item.performer != undefined ? 'current' : '') + '"><li>输血开始</li><li class="content_mid"><div class="line"></div><div class="circle">6</div></li><li>' + ((item.performTime == undefined || item.performTime == '') ? '' : item.performTime) + '</li> <li>' + ((item.performer == undefined || item.performer == '') ? ((item.checker == undefined || item.checker == '') ? '' : item.checker) : ((item.checker == undefined || item.checker == '') ? item.performer : item.performer + '/' + item.checker)) + '</li></ul></li>' +
                                        '<li><ul class="main_content ' + (item.endPerformer != '' && item.endPerformer != undefined ? 'current' : '') + '"><li>输血结束</li><li class="content_mid"><div class="line"></div><div class="circle">7</div></li><li>' + (item.endPerformTime == undefined ? '' : item.endPerformTime) + '</li> <li>' + (item.endPerformer == undefined ? '' : item.endPerformer) + '</li></ul></li>' +
                                        '<li><ul class="main_content ' + (item.sendPerformer != '' && item.sendPerformer != undefined ? 'current' : '') + '"><li>血袋送出</li><li class="content_mid"><div class="line"></div><div class="circle">8</div></li><li>' + (item.sendPerformTime == undefined ? '' : item.sendPerformTime) + '</li> <li>' + (item.sendPerformer == undefined ? '' : item.sendPerformer) + '</li></ul></li>' +
                                        '<li><ul class="main_content ' + (item.backInOperator != '' && item.backInOperator != undefined ? 'current' : '') + '"><li>血袋回收</li><li class="content_mid"><div class="line"></div><div class="circle">9</div></li><li>' + (item.backInTime == undefined ? '' : item.backInTime) + '</li> <li>' + (item.backInOperator == undefined ? '' : item.backInOperator) + '</li></ul></li>' +
                                        '</ul>' +
                                        '</div>'
                                    str = "<td class='jsgrid-cell chk' colspan='20' style='text-align:center;'>" + string + "</td>";
                                } else {
                                    str += "<td style='width: 0px;' class='jsgrid-cell hide'>" + (item.transfusionId == undefined ? '' : item.transfusionId) + "</td>"
                                        + "<td style='width: 0px;' class='jsgrid-cell hide'>" + (item.sampleId == undefined ? '' : item.sampleId) + "</td>"
                                        + "<td style='width: 0px;' class='jsgrid-cell hide'>" + (item.orderId == undefined ? '' : item.orderId) + "</td>"
                                        + "<td style='width: 0px;' class='jsgrid-cell hide'>" + (item.inpatientId == undefined ? '' : item.inpatientId) + "</td>"
                                        + "<td style='width: 0px;' class='jsgrid-cell hide'>" + (item.hisOrderId == undefined ? '' : item.hisOrderId) + "</td>"
                                        + "<td style='width: 33px;' class='jsgrid-cell'>" + (item.rowIndex == undefined ? '' : item.rowIndex) + "</td>"
                                        + "<td style='width: 57px;' class='jsgrid-cell'>" + (item.bedNum == undefined ? '' : item.bedNum) + "</td>"
                                        + "<td style='width: 60px;' class='jsgrid-cell'>" + (item.NAME == undefined ? '' : item.NAME) + "</td>"
                                        + "<td style='width: 67px;' class='jsgrid-cell'>" + (item.patientNum == undefined ? '' : item.patientNum) + "</td>"
                                        + "<td style='width: 105px;' class='jsgrid-cell'>" + (item.sampleId == undefined ? '' : item.sampleId) + "</td>"
                                        + "<td style='width: 70px;' class='jsgrid-cell'>" + (item.bloodProductId == undefined ? '' : item.bloodProductId) + "</td>"
                                        + "<td style='width: 100px;' class='jsgrid-cell'>" + (item.bloodNameSpec == undefined ? '' : item.bloodNameSpec) + "</td>"
                                        + "<td style='width: 65px;' class='jsgrid-cell'><p class='statusText'>" + (item.statusText == undefined ? '' : item.statusText) + "</p></td>"
                                        + "<td style='width: 65px;' class='jsgrid-cell'><p class='sampleStatusText'>" + (item.sampleStatusText == undefined ? '' : item.sampleStatusText) + "</p></td>"
                                        + "<td style='width: 110px;' class='jsgrid-cell blood-time'>" + (item.bloodReciveTime == undefined ? '' : item.bloodReciveTime) + "</td>"
                                        + "<td style='width: 55px;' class='jsgrid-cell'>" + (item.bloodReciver == undefined ? '' : item.bloodReciver) + "</td>"
                                        + "<td style='width: 110px;' class='jsgrid-cell blood-time'>" + (item.performTime == undefined ? '' : item.performTime) + "</td>"
                                        + "<td style='width: 55px;' class='jsgrid-cell'>" + (item.performer == undefined ? '' : item.performer) + "</td>"
                                        + "<td style='width: 55px;' class='jsgrid-cell'>" + (item.checker == undefined ? '' : item.checker) + "</td>"
                                        + "<td style='width: 110px;' class='jsgrid-cell blood-time'>" + (item.endPerformTime == undefined ? '' : item.endPerformTime) + "</td>"
                                        + "<td style='width: 55px;' class='jsgrid-cell'>" + (item.endPerformer == undefined ? '' : item.endPerformer) + "</td>"
                                        + "<td style='width: 110px;' class='jsgrid-cell blood-time'>" + (item.sendPerformTime == undefined ? '' : item.sendPerformTime) + "</td>"
                                        + "<td style='width: 55px;' class='jsgrid-cell'>" + (item.sendPerformer == undefined ? '' : item.sendPerformer) + "</td>"
                                        + "<td style='width: 55px;' class='jsgrid-cell'>" + (item.performMemo == undefined ? '' : item.performMemo) + "</td>"
                                        + "<td style='width: 80px;' class='jsgrid-cell chk'><a id='handleExc' data-abo='" + (item.abo == undefined ? '' : item.abo) + "'  data-rh='" + (item.rh == undefined ? '' : item.rh) + "' data-bloodProductId='" + (item.bloodProductId == undefined ? '' : item.bloodProductId) + "'>异常处理</a></td>";
                                }
                                return $('<tr>').append(str);
                                Page.Event.canDragTable();
                            },
                            fields: [
                                { width: 0, title: '', css: "hide" },
                                { width: 0, title: '', css: "hide" },
                                { width: 0, title: '', css: "hide" },
                                { width: 0, title: '', css: "hide" },
                                { width: 0, title: '', css: "hide" },
                                { width: 33, title: '' },
                                { width: 57, title: '床号' },
                                { width: 60, title: '姓名', css: 'name' },
                                { width: 67, title: '病历号', css: 'print-num' },
                                { width: 105, title: '条码号', css: 'print-id' },
                                { width: 70, title: '血编号', css: 'blood-num' },
                                { width: 100, title: '血液名称规格', css: 'blood-name' },
                                { width: 65, title: '输血状态', css: 'print-name' },
                                { width: 65, title: '标本状态', css: 'print-name' },
                                { width: 110, title: '接收时间', css: 'blood-time' },
                                { width: 55, title: '接收人', css: 'print-name' },
                                { width: 110, title: '输血开始时间', css: "lg-title blood-time" },
                                { width: 55, title: '执行人', css: 'print-name' },
                                { width: 55, title: '核对人', css: 'print-name' },
                                { width: 110, title: '输血结束时间', css: 'blood-time' },
                                { width: 55, title: '执行人', css: 'print-name' },
                                { width: 110, title: '血袋送出时间', css: 'blood-time' },
                                { width: 55, title: '执行人', css: 'print-name' },
                                { width: 55, title: '备注' },
                                { width: 80, title: '操作', css: "exception" },
                            ],
                            data: result
                        });
                        if (result != "") {
                            $('.jsgrid-grid-body').find('td').css('border', '0');
                        }
                        $('.jsgrid-grid-body').find('tr:nth-child(odd)').css({ "border-left": "1px solid #ccc", "border-right": "1px solid #ccc" });
                        $('.jsgrid-grid-body').find('tr:nth-child(even)').css('border', '1px solid #ccc');

                    }
                    else if (order_type == pathologyNum) {
                        //病理
                        $("#gridList").empty();
                        $("#gridList").jsGrid({
                            height: "100%",
                            width: "100%",
                            sorting: false,
                            paging: false,
                            search: false,
                            rowRenderer: function (item) {
                                var str = "";
                                var F = item.sampleNo != undefined && item.sampleNo != "" && item.sampleNo.substr(0, 1) == "F" ? true : false;
                                if (item.flag == "flag") {
                                    var string = '<div id="step">' +
                                        '<ul>' +
                                        '<li><ul id="sampling' + item.sampleId + '" class="main_content ' + (item.sampler != '' && item.sampler != undefined ? 'current' : '') + '"><li>标本采集</li><li class="content_mid"><div class="circle">1</div></li><li id="samplingTime' + item.sampleId + '" >' + (item.samplingTime == undefined || item.samplingTime == '' || item.samplingTime == '0000-00-00 00:00:00' ? '时间待定' : item.samplingTime) + '</li> <li id="sampler' + item.sampleId + '" >' + (item.sampler == undefined ? '' : item.sampler) + '</li></ul></li>' +
                                        '<li ' + (F ? 'style="display:none"' : '') + '><ul id="fixed' + item.sampleId + '" class="main_content ' + (item.fixeder != '' && item.fixeder != undefined ? 'current' : '') + '"><li>标本固定</li><li class="content_mid"><div class="line"></div><div class="circle">2</div></li><li id="fixedTime' + item.sampleId + '">' + ((item.fixedTime == undefined || item.fixedTime == '' || item.fixedTime == '0000-00-00 00:00:00') ? '' : item.fixedTime) + '</li><li id="fixeder' + item.sampleId + '">' + (item.fixeder == undefined ? '' : item.fixeder) + '</li></ul></li>' +
                                        '<li><ul id="check' + item.sampleId + '" class="main_content ' + (item.checker != '' && item.checker != undefined ? 'current' : '') + '"><li>标本核对</li><li class="content_mid"><div class="line"></div><div class="circle">' + (F ? 2 : 3) + '</div></li><li id="checkTime' + item.sampleId + '" >' + (item.checkTime == undefined ? '' : item.checkTime) + '</li> <li id="checker' + item.sampleId + '" >' + (item.checker == undefined || item.checker == '' ? '' : item.checker) + '</li></ul></li>' +
                                        '<li ' + (F ? 'style="display:none"' : '') + '><ul id="sendcheck' + item.sampleId + '" class="main_content ' + (item.sendchecker != '' && item.sendchecker != undefined ? 'current' : '') + '"><li>送检护士核对</li><li class="content_mid"><div class="line"></div><div class="circle">' + (F ? 3 : 4) + '</div></li><li id="sendcheckTime' + item.sampleId + '" >' + ((item.sendcheckTime == undefined || item.sendcheckTime == '') ? '' : item.sendcheckTime) + '</li><li id="sendchecker' + item.sampleId + '" >' + (item.sendchecker == undefined || item.sendchecker == '' ? '' : item.sendchecker) + '</li></ul></li>' +
                                        '<li><ul id="send' + item.sampleId + '" class="main_content ' + (item.sender != '' && item.sender != undefined ? 'current' : '') + '"><li>标本送检</li><li class="content_mid"><div class="line"></div><div class="circle">' + (F ? 3 : 5) + '</div></li><li id="sendTime' + item.sampleId + '" >' + ((item.sendTime == undefined || item.sendTime == '') ? '' : item.sendTime) + '</li><li id="sender' + item.sampleId + '">' + (item.sender == undefined || item.sender == '' ? '' : item.sender) + '</li></ul></li>' +
                                        '<li><ul id="recive' + item.sampleId + '" class="main_content ' + (item.reciver != '' && item.reciver != undefined ? 'current' : '') + '"><li>标本接收</li><li class="content_mid"><div class="line"></div><div class="circle">' + (F ? 4 : 6) + '</div></li><li id="reciveTime' + item.sampleId + '">' + ((item.reciveTime == undefined || item.reciveTime == '') ? '' : item.reciveTime) + '</li> <li id="reciver' + item.sampleId + '">' + (item.reciver == undefined ? '' : item.reciver) + '</li></ul></li>' +
                                        '<li><ul id="report' + item.sampleId + '" class="main_content ' + (item.reporter != '' && item.reporter != undefined ? 'current' : '') + '"><li>标本报告</li><li class="content_mid"><div class="line"></div><div class="circle">' + (F ? 5 : 7) + '</div></li><li id="reportTime' + item.sampleId + '">' + ((item.reportTime == undefined || item.reportTime == '') ? '' : item.reportTime) + '</li> <li id="reporter' + item.sampleId + '">' + (item.reporter == undefined ? '' : item.reporter) + '</li></ul></li>' +
                                        '</ul>' +
                                        '</div>'
                                    str = "<td class='jsgrid-cell chk' colspan='13' style='text-align:center;'>" + string + "</td>";
                                } else {
                                    str += "<td style='width: 0px;' class='jsgrid-cell hide' data-id='transfusionId'>" + (item.treatmentId == undefined ? '' : item.treatmentId) + "</td>"
                                        + "<td style='width: 0px;' class='jsgrid-cell hide' data-id='sampleId'>" + (item.sampleId == undefined ? '' : item.sampleId) + "</td>"
                                        + "<td style='width: 0px;' class='jsgrid-cell hide' data-id='inpatientId'>" + (item.inpatientId == undefined ? '' : item.inpatientId) + "</td>"
                                        + "<td style='width: 35px;' class='jsgrid-cell' data-id='rowIndex'>" + (item.rowIndex == undefined ? '' : item.rowIndex) + "</td>"

                                        + "<td style='width: 65px;' class='jsgrid-cell' data-id='bedNum'>" + (item.bedNum == undefined ? '' : item.bedNum) + "</td>"
                                        + "<td style='width: 70px;' class='jsgrid-cell' data-id='patientName'>" + (item.patientName == undefined ? '' : item.patientName) + "</td>"
                                        + "<td style='width: 100px;' class='jsgrid-cell' data-id='treatmentNo'>" + (item.treatmentNo == undefined ? '' : item.treatmentNo) + "</td>"

                                        + "<td style='width: 105px;' class='jsgrid-cell' data-id='sampleId2'>" + (item.sampleId == undefined ? '' : item.sampleId) + "</td>"
                                        + "<td style='width: 100px;' class='jsgrid-cell' data-id='sampleNo'>" + (item.sampleNo == undefined ? '' : item.sampleNo) + "</td>"

                                        + "<td style='width: 100px;' class='jsgrid-cell' data-id='sampleName'><p class='sampleName'>" + (item.sampleName == undefined ? '' : item.sampleName) + "</p></td>"
                                        + "<td style='width: 100px;' class='jsgrid-cell' data-id='checkItem'><p class='checkItem'>" + (item.checkItem == undefined ? '' : item.checkItem) + "</p></td>"
                                        + "<td style='width: 70px;' class='jsgrid-cell' data-id='sampleStatusText'><p class='sampleStatusText'>" + (item.sampleStatusText == undefined ? '' : item.sampleStatusText) + "</p></td>"

                                        + "<td style='width: 110px;' class='jsgrid-cell blood-time' data-id='reciveTime'>" + (item.reciveTime == undefined ? '' : item.reciveTime) + "</td>"
                                        + "<td style='width: 60px;' class='jsgrid-cell' data-id='reciver'>" + (item.reciver == undefined ? '' : item.reciver) + "</td>"
                                        + "<td style='width: 110px;' class='jsgrid-cell blood-time' data-id='reportTime'>" + (item.reportTime == undefined ? '' : item.reportTime) + "</td>"
                                        + "<td style='width: 80px;' class='jsgrid-cell chk'><a id='handleExc" + item.rowIndex + "' class='blby' ' data-sampleId='" + (item.sampleId == undefined ? '' : item.sampleId) + "'>异常处理</a></td>";
                                }
                                return $('<tr>').append(str);
                                Page.Event.canDragTable();
                            },
                            fields: [
                                { width: 0, title: '', css: "hide" },
                                { width: 0, title: '', css: "hide" },
                                { width: 0, title: '', css: "hide" },
                                { width: 35, title: '' },

                                { width: 65, title: '床号' },
                                { width: 70, title: '姓名', css: 'name' },
                                { width: 100, title: '就诊卡号', css: 'print-num' },

                                { width: 105, title: '条码号', css: 'print-id' },
                                { width: 100, title: '病理号', css: 'blood-num' },

                                { width: 100, title: '病理名称规格', css: 'blood-name' },
                                { width: 100, title: '项目名称', css: 'blood-name' },
                                { width: 70, title: '标本状态', css: 'print-name' },

                                { width: 110, title: '接收时间', css: 'blood-time' },
                                { width: 60, title: '接收人', css: 'print-name' },
                                { width: 110, title: '报告时间', css: 'reporting-time' },
                                { width: 80, title: '操作', css: "exception" },
                            ],
                            data: result
                        });
                        if (result != "") {
                            $('.jsgrid-grid-body').find('td').css('border', '0');
                        }
                        $('.jsgrid-grid-body').find('tr:nth-child(odd)').css({ "border-left": "1px solid #ccc", "border-right": "1px solid #ccc" });
                        $('.jsgrid-grid-body').find('tr:nth-child(even)').css('border', '1px solid #ccc');

                    }
                    else {
                        if ($("#medicine").val() == "kfy" || $("#geiyaoWays").val() == "51" || $("#口服51").prop("checked")) {
                            $("#gridList").jsGrid({
                                height: "100%",
                                width: "100%",
                                sorting: false,
                                paging: false,
                                search: false,
                                rowRenderer: null,
                                fields: [
                                    { name: "inpatientId", width: 0, title: '', css: "hide cssinpatientId" },
                                    { name: "performGroupId", width: 0, title: '', css: "hide cssperformGroupId" },
                                    { name: "performScheduleIds", width: 0, title: '', css: "hide cssperformScheduleIds" },
                                    { name: "hisOrderIds", width: 0, title: '', css: "hide csshisOrderIds" },
                                    /*                                 {
                                                                        itemTemplate:function(value,item){
                                                                            return $("<input>").attr("type","checkbox").attr("name","batchChk")
                                                                                .on("change",function(){
                                                                                    Page.Event.batchCheck(this);
                                                                                });
                                                                        },
                                                                        title:"",
                                                                        align: "center",
                                                                        width: 30,
                                                                        css:"hide chk",
                                                                    }, */
                                    { name: "rowIndex", type: "text", width: 33, title: '', css: 'cssrowIndex' },
                                    { name: "bedNum", type: "number", width: 57, title: '床号', css: 'cssbedNum' },
                                    { name: "name", type: "text", width: 51, title: '姓名', css: 'print-name cssname' },
                                    { name: "patientNum", type: "text", width: 67, title: '病历号', css: 'csspatientNum' },
                                    {
                                        itemTemplate: function (value, item) {
                                            var html = "";
                                            if (item.mayFall == "F") { html += '<span class="isDanger">' + item.mayFall + '</span>'; }
                                            if (item.dangerDrug == "危") { html += '<span class="isDanger">' + item.dangerDrug + '</span>'; }
                                            if (item.narcotic == "麻") { html += '<span class="isDanger">' + item.narcotic + '</span>'; }
                                            if (html != "") { return $('<i>').html(html); }
                                            else { return; }
                                            // if (item.mayFall == "F" && item.dangerDrug == "危") {
                                            //     return $('<i>').html( '<span class="isDanger">'+item.mayFall+'</span> <span class="isDanger">'+item.dangerDrug+'</span>');
                                            // }else if(item.mayFall == "F" && item.dangerDrug != "危") {
                                            //     return $('<i>').html( '<span class="isDanger">'+item.mayFall+'</span>');
                                            // }else if(item.mayFall != "F" && item.dangerDrug == "危") {
                                            //     return $('<i>').html( '<span class="isDanger">'+item.dangerDrug+'</span>');
                                            // }else {
                                            //     return;
                                            // }
                                        },
                                        title: "高危",
                                        align: "center",
                                        width: 40,
                                        css: "danger cssemc",
                                    },
                                    {
                                        itemTemplate: function (value, item) {
                                            html = item.orderName;
                                            if ($("#orderType").val() == "2") {
                                                html = html.replace("1.0000", "");
                                            } else {
                                                html = item.orderName2;
                                            }
                                            return html;
                                        },
                                        title: "药品",
                                        align: "center",
                                        width: 140,
                                        css: "ordername cssorderName",
                                    },
                                    { name: "supplyName", type: "text", width: 61, title: '用法', css: 'print-supply csssupplyName' },
                                    { name: "frequency", type: "text", width: 50, title: '频率', css: 'cssfrequency' },
                                    { name: "schedulePerformTime", type: "time", width: 110, title: '计划执行时间', css: 'print-plantime cssschedulePerformTime' },
                                    { name: "performStartTime", type: "text", width: 110, title: '实际执行时间', css: 'print-time cssperformStartTime' },
                                    { name: "performerStart", width: 122, title: '执行护士', css: 'cssperformerStart' },
                                    { name: "emcPerformTime", width: 110, title: '核对时间', css: 'hide cssemcPerformTime' },
                                    { name: "emcPerformer", width: 0, title: '核对人', css: 'hide cssemcPerformer' },
                                    { name: "completeTime", width: 110, title: '结束时间', css: 'print-time csscompleteTime' },
                                    { name: "performerComplete", width: 61, title: '结束护士', css: 'cssperformerComplete' },
                                    { name: "performStatusName", width: 61, title: '执行状态', css: 'cssperformStatusName' },
                                    { name: "performMemo", width: 78, title: '执行状态', css: 'cssperformMemo' },
                                    {
                                        itemTemplate: function (_, item) {
                                            return $("<a>").text("异常处理").
                                            on("click", function () {
                                                indexId++;
                                                $(this).parent().parent().attr('id', 'index' + indexId);
                                                $(this).parent().parent().addClass('blue').siblings().removeClass('blue');
                                                Page.Event.openPage(this, 'index' + indexId);
                                            });
                                        },
                                        title: '操作',
                                        align: "center",
                                        width: 80,
                                        css: "exception"
                                    },
                                    { name: "hisScheduleIds", width: 0, title: '', css: "hide csshisScheduleIds" },
                                    { name: "standingOrder", width: 0, title: '', css: "hide cssstandingOrder" },
                                    { name: "groupId", width: 0, title: '', css: "hide cssgroupId" },
                                    {
                                        itemTemplate: function (value, item) {
                                            return $("<input>").attr("type", "checkbox").attr("name", "geiyaoWays").attr("incrementId", item.incrementId)
                                                .on("change", function () {
                                                    Page.Event.checkBoxs(this);
                                                });
                                        },
                                        title: "按钮",
                                        align: "center",
                                        width: 30,
                                        css: "hide  cssgeiyaoWays",
                                    }
                                ],
                                data: result

                            });
                        } else {
                            // 开嘱时间
                            var _args1 = { parameterName: '开嘱时间' };
                            if (isOpenRole(_args1) == 1) {  //先判断系统参数是否为    1
                                $("#gridList").jsGrid({
                                    height: "100%",
                                    width: "100%",
                                    sorting: false,
                                    paging: false,
                                    search: false,
                                    rowRenderer: null,
                                    fields: [
                                        { name: "inpatientId", width: 0, title: '', css: "hide cssinpatientId" },
                                        { name: "performGroupId", width: 0, title: '', css: "hide cssperformGroupId" },
                                        {
                                            name: "performScheduleIds",
                                            width: 0,
                                            title: '',
                                            css: "hide cssperformScheduleIds"
                                        },
                                        { name: "hisOrderIds", width: 0, title: '', css: "hide csshisOrderIds" },
                                        {
                                            itemTemplate: function (value, item) {
                                                return $("<input>").attr("type", "checkbox").attr("name", "batchChk")
                                                    .on("change", function () {
                                                        Page.Event.batchCheck(this);
                                                    });
                                            },
                                            title: "",
                                            align: "center",
                                            width: 30,
                                            css: "hide chk",
                                        },
                                        { name: "rowIndex", type: "text", width: 33, title: '', css: 'cssrowIndex' },
                                        { name: "bedNum", type: "text", width: 57, title: '床号', css: 'cssbedNum' },
                                        { name: "name", type: "text", width: 51, title: '姓名', css: 'print-name cssname' },
                                        { name: "patientNum", type: "text", width: 67, title: '病历号', css: 'csspatientNum' },
                                        {
                                            itemTemplate: function (value, item) {
                                                var html = "";
                                                if (item.mayFall == "F") {
                                                    html += '<span class="isDanger">' + item.mayFall + '</span>';
                                                }
                                                if (item.dangerDrug == "危") {
                                                    html += '<span class="isDanger">' + item.dangerDrug + '</span>';
                                                }
                                                if (item.narcotic == "麻") {
                                                    html += '<span class="isDanger">' + item.narcotic + '</span>';
                                                }
                                                if (html != "") {
                                                    return $('<i>').html(html);
                                                } else {
                                                    return;
                                                }


                                                // if (item.mayFall == "F" && item.dangerDrug == "危") {
                                                //     return $('<i>').html( '<span class="isDanger">'+item.mayFall+'</span> <span class="isDanger">'+item.dangerDrug+'</span>');
                                                // }else if(item.mayFall == "F" && item.dangerDrug != "危") {
                                                //     return $('<i>').html( '<span class="isDanger">'+item.mayFall+'</span>');
                                                // }else if(item.mayFall != "F" && item.dangerDrug == "危") {
                                                //     return $('<i>').html( '<span class="isDanger">'+item.dangerDrug+'</span>');
                                                // }else {
                                                //     return;
                                                // }
                                            },
                                            title: "高危",
                                            align: "center",
                                            width: 40,
                                            css: "danger cssemc",
                                        },
                                        {
                                            name: "orderName",
                                            type: "text",
                                            width: 140,
                                            title: '药品',
                                            css: 'ordername cssorderName'
                                        },
                                        {
                                            name: "supplyName",
                                            type: "text",
                                            width: 61,
                                            title: '用法',
                                            css: 'print-supply csssupplyName'
                                        },
                                        { name: "frequency", type: "text", width: 50, title: '频率', css: 'cssfrequency' },
                                        {
                                            name: "startTime",
                                            type: "text",
                                            width: 110,
                                            title: '开嘱时间',
                                            css: 'print-plantime cssstartTime'
                                        },
                                        {
                                            name: "schedulePerformTime",
                                            type: "time",
                                            width: 110,
                                            title: '计划执行时间',
                                            css: 'print-plantime cssschedulePerformTime'
                                        },
                                        {
                                            name: "performStartTime",
                                            type: "text",
                                            width: 110,
                                            title: '实际执行时间',
                                            css: 'print-time cssperformStartTime'
                                        },
                                        { name: "performerStart", width: 122, title: '执行护士', css: 'cssperformerStart' },
                                        { name: "emcPerformTime", width: 110, title: '核对时间', css: 'hide cssemcPerformTime' },
                                        { name: "emcPerformer", width: 0, title: '核对人', css: 'hide cssemcPerformer' },
                                        {
                                            name: "completeTime",
                                            width: 110,
                                            title: '结束时间',
                                            css: 'print-time csscompleteTime'
                                        },
                                        { name: "performerComplete", width: 61, title: '结束护士', css: 'cssperformerComplete' },
                                        {
                                            itemTemplate: function (value, item) {
                                                html = "";
                                                if (isshowds == "1") {
                                                    html = item.shuyedisu;
                                                } else if (isshowds == "2") {
                                                    html = item.driprate;
                                                }
                                                return html;
                                            },
                                            title: "输液滴速",
                                            align: "center",
                                            width: 61,
                                            css: "hide cssshuyedisu",
                                        },
                                        //{ name: "shuyedisu",width: 61, title: '输液滴速',css:'hide cssshuyedisu'},
                                        { name: "performStatusName", width: 61, title: '执行状态', css: 'cssperformStatusName' },
                                        { name: "performMemo", width: 78, title: '备注', css: 'cssperformMemo' },
                                        {
                                            itemTemplate: function (_, item) {
                                                return $("<a>").text("异常处理").on("click", function () {
                                                    indexId++;
                                                    $(this).parent().parent().attr('id', 'index' + indexId);
                                                    $(this).parent().parent().addClass('blue').siblings().removeClass('blue');
                                                    Page.Event.openPage(this, 'index' + indexId);
                                                });
                                            },
                                            title: '操作',
                                            align: "center",
                                            width: 80,
                                            css: "exception"
                                        },

                                        { name: "hisScheduleIds", width: 0, title: '', css: "hide csshisScheduleIds" },
                                        { name: "standingOrder", width: 0, title: '', css: "hide cssstandingOrder" },
                                        { name: "groupId", width: 0, title: '', css: "hide cssgroupId" },
                                        {
                                            itemTemplate: function (value, item) {
                                                return $("<input>").attr("type", "checkbox").attr("name", "geiyaoWays").attr("incrementId", item.incrementId)
                                                    .on("change", function () {
                                                        Page.Event.checkBoxs(this);
                                                    });
                                            },
                                            title: "按钮",
                                            align: "center",
                                            width: 30,
                                            css: "hide  cssgeiyaoWays",
                                        },
                                    ],
                                    data: result

                                });
                            } else {
                                $("#gridList").jsGrid({
                                    height: "100%",
                                    width: "100%",
                                    sorting: false,
                                    paging: false,
                                    search: false,
                                    rowRenderer: null,
                                    fields: [
                                        { name: "inpatientId", width: 0, title: '', css: "hide cssinpatientId" },
                                        { name: "performGroupId", width: 0, title: '', css: "hide cssperformGroupId" },
                                        {
                                            name: "performScheduleIds",
                                            width: 0,
                                            title: '',
                                            css: "hide cssperformScheduleIds"
                                        },
                                        { name: "hisOrderIds", width: 0, title: '', css: "hide csshisOrderIds" },
                                        {
                                            itemTemplate: function (value, item) {
                                                return $("<input>").attr("type", "checkbox").attr("name", "batchChk")
                                                    .on("change", function () {
                                                        Page.Event.batchCheck(this);
                                                    });
                                            },
                                            title: "",
                                            align: "center",
                                            width: 30,
                                            css: "hide chk",
                                        },
                                        { name: "rowIndex", type: "text", width: 33, title: '', css: 'cssrowIndex' },
                                        { name: "bedNum", type: "text", width: 57, title: '床号', css: 'cssbedNum' },
                                        { name: "name", type: "text", width: 51, title: '姓名', css: 'print-name cssname' },
                                        { name: "patientNum", type: "text", width: 67, title: '病历号', css: 'csspatientNum' },
                                        {
                                            itemTemplate: function (value, item) {
                                                var html = "";
                                                if (item.mayFall == "F") {
                                                    html += '<span class="isDanger">' + item.mayFall + '</span>';
                                                }
                                                if (item.dangerDrug == "危") {
                                                    html += '<span class="isDanger">' + item.dangerDrug + '</span>';
                                                }
                                                if (item.narcotic == "麻") {
                                                    html += '<span class="isDanger">' + item.narcotic + '</span>';
                                                }
                                                if (html != "") {
                                                    return $('<i>').html(html);
                                                } else {
                                                    return;
                                                }


                                                // if (item.mayFall == "F" && item.dangerDrug == "危") {
                                                //     return $('<i>').html( '<span class="isDanger">'+item.mayFall+'</span> <span class="isDanger">'+item.dangerDrug+'</span>');
                                                // }else if(item.mayFall == "F" && item.dangerDrug != "危") {
                                                //     return $('<i>').html( '<span class="isDanger">'+item.mayFall+'</span>');
                                                // }else if(item.mayFall != "F" && item.dangerDrug == "危") {
                                                //     return $('<i>').html( '<span class="isDanger">'+item.dangerDrug+'</span>');
                                                // }else {
                                                //     return;
                                                // }
                                            },
                                            title: "高危",
                                            align: "center",
                                            width: 40,
                                            css: "danger cssemc",
                                        },
                                        /*                                     {
                                                                                name: "orderName",
                                                                                type: "text",
                                                                                width: 140,
                                                                                title: '药品',
                                                                                css: 'ordername cssorderName'
                                                                            }, */
                                        {
                                            itemTemplate: function (value, item) {
                                                html = item.orderName;
                                                if ($("#orderType").val() == "2") {
                                                    html = html.replace("1.0000", "");
                                                } else {
                                                    html = item.orderName2;
                                                }
                                                return html;
                                            },
                                            title: "药品",
                                            align: "center",
                                            width: 140,
                                            css: "ordername cssorderName",
                                        },
                                        {
                                            name: "supplyName",
                                            type: "text",
                                            width: 61,
                                            title: '用法',
                                            css: 'print-supply csssupplyName'
                                        },
                                        { name: "frequency", type: "text", width: 50, title: '频率', css: 'cssfrequency' },
                                        // {
                                        //     name: "startTime",
                                        //     type: "text",
                                        //     width: 110,
                                        //     title: '开嘱时间',
                                        //     css: 'print-plantime cssstartTime'
                                        // },
                                        {
                                            name: "schedulePerformTime",
                                            type: "time",
                                            width: 110,
                                            title: '计划执行时间',
                                            css: 'print-plantime cssschedulePerformTime'
                                        },
                                        {
                                            name: "performStartTime",
                                            type: "text",
                                            width: 110,
                                            title: '实际执行时间',
                                            css: 'print-time cssperformStartTime'
                                        },
                                        { name: "performerStart", width: 122, title: '执行护士', css: 'cssperformerStart' },
                                        { name: "emcPerformTime", width: 110, title: '核对时间', css: 'hide cssemcPerformTime' },
                                        { name: "emcPerformer", width: 0, title: '核对人', css: 'hide cssemcPerformer' },
                                        {
                                            name: "completeTime",
                                            width: 110,
                                            title: '结束时间',
                                            css: 'print-time csscompleteTime'
                                        },
                                        { name: "performerComplete", width: 61, title: '结束护士', css: 'cssperformerComplete' },
                                        {
                                            itemTemplate: function (value, item) {
                                                html = "";
                                                if (isshowds == "1") {
                                                    html = item.shuyedisu;
                                                } else if (isshowds == "2") {
                                                    html = item.driprate;
                                                }
                                                return html;
                                            },
                                            title: "输液滴速",
                                            align: "center",
                                            width: 61,
                                            css: "hide cssshuyedisu",
                                        },
                                        //{ name: "shuyedisu",width: 61, title: '输液滴速',css:'hide cssshuyedisu'},
                                        { name: "performStatusName", width: 61, title: '执行状态', css: 'cssperformStatusName' },
                                        { name: "performMemo", width: 78, title: '备注', css: 'cssperformMemo' },
                                        {
                                            itemTemplate: function (_, item) {
                                                return $("<a>").text("异常处理").on("click", function () {
                                                    indexId++;
                                                    $(this).parent().parent().attr('id', 'index' + indexId);
                                                    $(this).parent().parent().addClass('blue').siblings().removeClass('blue');
                                                    Page.Event.openPage(this, 'index' + indexId);
                                                });
                                            },
                                            title: '操作',
                                            align: "center",
                                            width: 80,
                                            css: "exception"
                                        },

                                        { name: "hisScheduleIds", width: 0, title: '', css: "hide csshisScheduleIds" },
                                        { name: "standingOrder", width: 0, title: '', css: "hide cssstandingOrder" },
                                        { name: "groupId", width: 0, title: '', css: "hide cssgroupId" },
                                        {
                                            itemTemplate: function (value, item) {
                                                return $("<input>").attr("type", "checkbox").attr("name", "geiyaoWays").attr("incrementId", item.incrementId)
                                                    .on("change", function () {
                                                        Page.Event.checkBoxs(this);
                                                    });
                                            },
                                            title: "按钮",
                                            align: "center",
                                            width: 30,
                                            css: "hide  cssgeiyaoWays",
                                        },
                                    ],
                                    data: result

                                });
                            }
                        }
                    }


                    //var _args1 = {parameterName:'巡视卡显示输液滴速'};
                    //if(isOpenRole(_args1)!=""&&isOpenRole(_args1)!=null&&isOpenRole(_args1) == 1) {  //先判断系统参数是否为    1
                    if (isshowds == "1" || isshowds == "2") {
                        var tr = $("#gridList").find(".jsgrid-table").find("tr");
                        $.each(tr, function (i, n) {
                            $(n).find("th.cssshuyedisu").removeClass("hide");
                            $(n).find("td.cssshuyedisu").removeClass("hide");
                        });
                    }

                    //num = isOpenRole({parameterName:'巡视卡给药方式'});                  //判断系统参数      1 就显示给药方式
                    //if(num!=""&&num!=null&&num == 1){
                    //    $("#geiyaoDiv").show();
                    //    $("#geiyaoDiv").removeClass("hide");
                    //}



                    num2 = isOpenRole({ parameterName: '巡视卡打印复选框' });
                    //if(num2!=""&&num2!=null&&num2 == 1) {
                    var tr = $("#gridList").find(".jsgrid-table").find("tr");
                    $.each(tr, function (i, n) {                                       //判断系统参数        1 显示打印复选框按钮
                        $(n).find("th.cssgeiyaoWays").removeClass("hide");
                        $(n).find("td.cssgeiyaoWays").removeClass("hide");
                    });
                    //}

                    var gyfslist = new Array();
                    $('#mutipleDiv ul input:checkbox:checked').each(function () {
                        gyfslist.push($(this).val());//向数组中添加元素
                    });

                    if ($("#medicine").val() == "kfy" || $("#geiyaoWays").val() == "51" || $("#口服51").prop("checked")) {
                        $("input[name='batchChk']").parent().removeClass("hide");
                    } else {
                        $("input[name='batchChk']").parent().addClass("hide");
                    }
                    $('.danger span').each(function () {
                        if ($(this).text() == "危" || $(this).text() == "F" || $(this).text() == "麻") {
                            $(this).addClass('isDanger');
                        } else {
                            $(this).removeClass('isDanger')
                        }
                    })

                    $(".test-danger").each(function () {
                        var emergency = $(this).text();
                        if (emergency != "") {
                            $(this).next().addClass("test-danger");
                        }
                    });
                    //Page.Event.resizeTableWidth();
                }).fail(function (res) {
                    $("#tbList").find("tbody").empty();
                    $("#tbTestList").find("tbody").empty().html(res);
                    layer.error("服务器连接超时!", res.responseText);
                });

            },
            //口服药复选框
            batchCheck: function (_this) {
                if ($(_this).prop("checked") == true) {
                    $(_this).prop("checked", false);
                    $(_this).parent().parent().addClass("checkedRow");
                } else {
                    if ($("input[name='batchChk']:checked").length < 5) {
                        $(_this).prop("checked", true);
                        $(_this).parent().parent().removeClass("checkedRow");
                    } else {
                        layer.msg("最多只能选择5个");
                        $(_this).prop("checked", false);
                    }
                }
            },

            //选择打印复选框
            checkBoxs: function (_this) {
                if ($(_this).prop("checked") == true) {
                    $(_this).prop("checked", true);
                    $(_this).parent().parent().addClass("checkedRow");
                } else {
                    $(_this).prop("checked", false);
                    $(_this).parent().parent().removeClass("checkedRow");
                }
            },


            //打开药品类异常处理页面
            openPage: function (_this, index) {
                if ($.inArray(ROLERIGHT.update, roleRight) < 0) { //判断是否有编辑修改的的权限
                    layer.msg(roleRightTipMsg, { icon: 2 });
                    return;
                }


                //是否需要呈报
                var isReprot = false;
                var supplyName = $(_this).parent().parent().find("td:eq(11)").text();
                var suppList = ["静滴", "静推", "雾化", "皮下注射", "肌注", "微泵静推", "封管用", "滴眼"];
                //药品类型:如果选中是大量和小量，输液反应要呈报
                var medicineType = $('#medicine').val();
                if (medicineType != undefined && (medicineType == 'jd' || medicineType == 'zs' || (medicineType == 'all' && $.inArray(supplyName, suppList) > -1))) {
                    isReprot = true;
                }
                //获取数据
                // var inpatientId= $(_this).parent().parent().find("td:eq(0)").text();
                // var performGroupId= $(_this).parent().parent().find("td:eq(1)").text();
                // var performScheduleIds= $(_this).parent().parent().find("td:eq(2)").text();
                // var hisOrderIds= $(_this).parent().parent().find("td:eq(3)").text();
                // var hisScheduleIds= $(_this).parent().parent().find("td:eq(24)").text();
                // var standingOrder= $(_this).parent().parent().find("td:eq(25)").text();
                // var emc = $(_this).parent().parent().find("td:eq(9)").text();
                // var supplyName= $(_this).parent().parent().find("td:eq(11)").text();
                // var schedulePerformTime= $(_this).parent().parent().find("td:eq(13)").text();
                // var emcPerformTime= $(_this).parent().parent().find("td:eq(16)").text();
                // var emcPerformer= $(_this).parent().parent().find("td:eq(17)").text();
                // var groupId= $(_this).parent().parent().find("td:eq(26)").text();
                // var dealwithStatus= $(_this).parent().parent().find("td:eq(20)").text();

                var inpatientId = $(_this).parent().parent().find("td.cssinpatientId").text();
                var performGroupId = $(_this).parent().parent().find("td.cssperformGroupId").text();
                var performScheduleIds = $(_this).parent().parent().find("td.cssperformScheduleIds").text();
                var hisOrderIds = $(_this).parent().parent().find("td.csshisOrderIds").text();
                var hisScheduleIds = $(_this).parent().parent().find("td.csshisScheduleIds").text();
                var standingOrder = $(_this).parent().parent().find("td.cssstandingOrder").text();
                var emc = $(_this).parent().parent().find("td.cssemc").text();
                var supplyName = $(_this).parent().parent().find("td.csssupplyName").text();
                var schedulePerformTime = $(_this).parent().parent().find("td.cssschedulePerformTime").text();
                var emcPerformTime = $(_this).parent().parent().find("td.cssemcPerformTime").text();
                var emcPerformer = $(_this).parent().parent().find("td.cssemcPerformer").text();
                var groupId = $(_this).parent().parent().find("td.cssgroupId").text();
                var dealwithStatus = $(_this).parent().parent().find("td.cssperformStatusName").text();
                var state = '';
                if (argUrl.state != "" && argUrl.state != null && argUrl.state == "3") {
                    state = '3';
                }
                emc = emc.indexOf('危') > -1 || emc.indexOf('F') > -1 || emc.indexOf('麻') > -1 ? '危' : emc;
                //添加日志判断标志
                var performOperate = $('#pageFlag').val();
                var comeUrl = "";
                if (performOperate == 'performOperate') {
                    comeUrl = "/instruction/perform";
                } else {
                    comeUrl = "/patrolcard/index";
                }
                //打开页面
                layer.open({
                    type: 2,
                    title: '异常处理',
                    shift: '',
                    content: '/patrolcard/exception?order_type=' + order_type + '&dealwithStatus=' + dealwithStatus + '&isDanger=' + emc + '&supplyName=' + encodeURI(supplyName) + '&inpatientId=' + inpatientId + '&performGroupId=' + encodeURI(performGroupId) + '&trId=' + index + '&hisScheduleIds=' + encodeURI(hisScheduleIds) + '&standingOrder=' + standingOrder + '&comeUrl=' + encodeURI(comeUrl)
                        + '&hisOrderIds=' + encodeURI(hisOrderIds) + '&performScheduleIds=' + encodeURI(performScheduleIds) + '&emc=' + encodeURI(emc) + '&emcPerformTime=' + encodeURI(emcPerformTime) + '&emcPerformer=' + encodeURI(emcPerformer) + '&schedulePerformTime=' + encodeURI(schedulePerformTime) + '&groupId=' + encodeURI(groupId) + '&isReprot=' + encodeURI(isReprot) + '&state=' + state,
                    area: ['450px', '450px'],
                    success: function () { },
                    zIndex: '200',
                    scrolling: 'no'
                })
            },
            //打开检验异常处理页面
            openTestPage: function (_this, index) {
                var orderId = $(_this).parent().parent().find("td:eq(0)").text();
                var sampleId = $(_this).parent().parent().find("td:eq(1)").text();
                var samplerId = $(_this).parent().parent().find("td:eq(2)").text();
                var senderId = $(_this).parent().parent().find("td:eq(3)").text();
                var inpatientId = $(_this).parent().parent().find("td:eq(4)").text();
                var hisOrderIds = $(_this).parent().parent().find("td:eq(5)").text();
                var orderName = $(_this).parent().parent().find("td:eq(11)").text();
                var samplingTime = $(_this).parent().parent().find("td:eq(16)").text();
                var sendTime = $(_this).parent().parent().find("td:eq(18)").text();
                var schedulePerformTime = $(_this).parent().parent().find("td:eq(14)").text();
                var state = '';
                if (argUrl.state != "" && argUrl.state != null && argUrl.state == "3") {
                    state = '3';
                }

                //添加日志判断标志
                var performOperate = $('#pageFlag').val();
                var comeUrl = "";
                if (performOperate == 'performOperate') {
                    comeUrl = "/instruction/perform";
                } else {
                    comeUrl = "/patrolcard/index";
                }
                if (sampleId == "") {
                    layer.alert("暂无检验信息！", { icon: 2 });
                } else {

                    if ($.inArray(ROLERIGHT.update, roleRight) < 0) { //判断是否有编辑修改的的权限
                        layer.msg(roleRightTipMsg, { icon: 2 });
                        return;
                    }

                    layer.open({
                        type: 2,
                        title: '检验记录修改',
                        shift: '',
                        content: '/patrolcard/exception?order_type=' + order_type + '&orderid=' + orderId + '&sampleId=' + sampleId + '&inpatientId=' + inpatientId + '&hisOrderIds=' + encodeURI(hisOrderIds) + '&comeUrl=' + encodeURI(comeUrl)
                            + '&samplerId=' + samplerId + '&senderId=' + senderId + '&samplingTime=' + encodeURI(samplingTime) + '&sendTime=' + encodeURI(sendTime) + '&trId=' + index + '&orderName=' + encodeURI(orderName) + '&schedulePerformTime=' + encodeURI(schedulePerformTime) + '&state=' + state,
                        area: ['550px', '390px'],
                        success: function () { },
                        zIndex: '200',
                        scrolling: 'no'
                    });
                }
            },
            //打开输血异常处理页面
            openTransfusionPage: function (_this, index) {
                var transfusionId = $(_this).parent().parent().find("td:eq(0)").text();
                var sampleId = $(_this).parent().parent().find("td:eq(1)").text();
                var orderId = $(_this).parent().parent().find("td:eq(2)").text();
                var inpatientId = $(_this).parent().parent().find("td:eq(3)").text();
                var hisOrderId = $(_this).parent().parent().find("td:eq(4)").text();
                var abo = $(_this).attr("data-abo");
                var rh = $(_this).attr("data-rh");
                var bloodProductId = $(_this).attr("data-bloodProductId");
                var state = '';
                if (argUrl.state != "" && argUrl.state != null && argUrl.state == "3") {
                    state = '3';
                }
                //添加日志判断标志
                var performOperate = $('#pageFlag').val();
                var comeUrl = "";
                if (performOperate == 'performOperate') {
                    comeUrl = "/instruction/perform";
                } else {
                    comeUrl = "/patrolcard/index";
                }
                //            if(transfusionId == ""){
                //                layer.alert("暂无血液制品信息！",{icon:2});
                //            }else{
                if ($.inArray(ROLERIGHT.update, roleRight) < 0) { //判断是否有编辑修改的的权限
                    layer.msg(roleRightTipMsg, { icon: 2 });
                    return;
                }
                layer.open({
                    type: 2,
                    title: '输血记录修改',
                    shift: '',
                    //content: '/patrolcard/exception?order_type='+order_type+'&inpatientId='+inpatientId+'&hisOrderId='+hisOrderId+'&transfusionId='+transfusionId+'&sampleId='+sampleId+'&orderId='+orderId+'&trId='+index+'&abo='+abo+'&rh='+rh+'&bloodProductId='+bloodProductId+'&comeUrl='+encodeURI(comeUrl),
                    content: '/customPage/edit?menuShortName=HandleTransfusion_shulan&order_type=' + order_type + '&inpatientId=' + inpatientId + '&hisOrderId=' + hisOrderId + '&transfusionId=' + transfusionId + '&sampleId=' + sampleId + '&orderId=' + orderId + '&trId=' + index + '&abo=' + abo + '&rh=' + rh + '&bloodProductId=' + bloodProductId + '&comeUrl=' + encodeURI(comeUrl) + '&state=' + state,
                    area: ['580px', '590px'],
                    success: function () { },
                    zIndex: '200',
                    scrolling: 'no'
                });
                //            }
            },
            //病理异常处理
            openPathologyPage: function (_this, index) {
                var inpatientId = $(_this).parent().parent().find("td[data-id='inpatientId']").text();
                var sampleId = $(_this).parent().parent().find("td[data-id='sampleId']").text();
                //添加日志判断标志
                var performOperate = $('#pageFlag').val();
                var comeUrl = "";
                var state = '';
                if (argUrl.state != "" && argUrl.state != null && argUrl.state == "3") {
                    state = '3';
                }
                if (performOperate == 'performOperate') {
                    comeUrl = "/instruction/perform";
                } else {
                    comeUrl = "/patrolcard/index";
                }
                layer.open({
                    type: 2,
                    title: '病理记录修改',
                    shift: '',
                    content: '/customPage/edit?menuShortName=pathologyHandle_shulan&order_type=' + order_type + '&inpatientId=' + inpatientId + '&sampleId=' + sampleId + '&trId=' + index + '&comeUrl=' + encodeURI(comeUrl) + '&state=' + state,
                    area: ['580px', '500px'],
                    success: function () { },
                    zIndex: '200',
                    scrolling: 'no'
                });
            },
            //病区切换
            changeWard: function () {
                $('body').on('change', '#sel_ward', function (event) {
                    var wardCode = $('#sel_ward').val();
                    var obj = {
                        ward_code: wardCode,
                    };
                    cache.add("wardId", $(this).val());//病区切换设置cache
                    Page.Event.patientInit();
                    Page.Event.getPatientsCount(obj);
                    Page.Event.getAllWardGroup();
                    $("input[name='allpatient']").prop("checked", false);
                    $("#btnQuery").trigger("click");
                });
            },
            initWard: function () {
                var wardId = cache.get("wardId");
                if (null != wardId && wardId.length > 0) {
                    //读取cache设置病区切换
                    if (wardId != $("#sel_ward").val()) {
                        $("#sel_ward option[value='" + wardId + "']").attr('selected', 'selected');
                        $('#sel_ward').change();
                    }
                }
            },
            //病人数
            getPatientsCount: function (obj) {
                var wardName = $('#sel_ward').find('option:selected').text();
                var length = $('#patientTable tbody tr').length;
                var isshow = $(".patient-index-not-found");
                if ($(isshow).is(":hidden")) {
                    $('#totalPatient').find('span').html('共' + length + '人(' + wardName + ')');
                } else {
                    $('#totalPatient').find('span').html('共0人(' + wardName + ')');
                }
            },
            //医嘱分类选择
            typeSelect: function () {
                $('#orderType').change(function () {
                    $("#gridList").empty();
                    var type = $('#orderType').val();
                    if (type == "1") {//药品
                        $('#medicineDiv').show();
                        if (isshowstanding == "true" && order_type == "1") {
                            $("#standingDiv").show();
                            $("#standingDiv").removeClass("hide");
                        }
                        if ((isshowgeiyao == "true" || isshowgeiyao == "1") && order_type == "1") {
                            $("#geiyaoDiv").show();
                            $("#geiyaoDiv").removeClass("hide");
                            $("#medicineDiv").addClass("hide");
                            $('#medicine').val('all');
                        }
                        $('#entryTypeDiv').css('display', 'none');
                        // $('input[name="medicine"]').attr("disabled",false);
                        // $('input[name="medicine"][value="all"]').prop("checked","checked");
                        //$("#performStatusDiv").removeClass("hide");
                        $("#sampleStatusDiv").addClass("hide");
                        $("#bloodStatusDiv").addClass("hide");
                        $("#sampleStatus").val("");
                        $("#bloodStatus").val("");

                        $("#pathologyStatusDiv").addClass("hide");
                        $("#pathologyStatus").val("");
                        // $('input[name="entryType"]').attr("checked",false);
                        // $('input[name="entryType"]').attr("disabled",true);

                        $("#geiyaoDiv").removeClass("hide");

                    } else if (type == "2") {//诊疗
                        $("#standingDiv").addClass("hide");
                        $("#standing").val("all");
                        $("#geiyaoDiv").addClass("hide");
                        $("#geiyaoWays").val("all");
                        $('#medicineDiv').hide();
                        $('#medicine').val('all');

                    } else if (type == "4") {//检验
                        // $('input[name="medicine"]').attr("checked",false);
                        // $('input[name="medicine"]').attr("disabled",true);
                        $("#standingDiv").addClass("hide");
                        $("#geiyaoDiv").addClass("hide");
                        $("#standing").val("all");
                        $("#geiyaoWays").val("all");

                        $('#medicineDiv').hide();
                        $('#entryTypeDiv').css('display', 'none');
                        $('#medicine').val('all');
                        $("#btnBatch").addClass("hide");
                        $("#performStatusDiv").addClass("hide");
                        $("#sampleStatusDiv").removeClass("hide");
                        $("#bloodStatusDiv").addClass("hide");
                        $("#performStatus").val("");
                        $("#bloodStatus").val("");

                        $("#pathologyStatusDiv").addClass("hide");
                        $("#pathologyStatus").val("");
                        // $('input[name="entryType"]').attr("checked",false);
                        // $('input[name="entryType"]').attr("disabled",true);
                    } else if (type == "0") {//输血记录
                        // $('input[name="medicine"]').attr("checked",false);
                        // $('input[name="medicine"]').attr("disabled",true);
                        $("#standingDiv").addClass("hide");
                        $("#geiyaoDiv").addClass("hide");
                        $("#standing").val("all");
                        $("#geiyaoWays").val("all");

                        $('#medicineDiv').hide();
                        $('#entryTypeDiv').css('display', 'block');
                        $('#medicine').val('all');
                        $("#btnBatch").addClass("hide");
                        $("#performStatusDiv").addClass("hide");
                        $("#sampleStatusDiv").addClass("hide");
                        $("#bloodStatusDiv").removeClass("hide");
                        $("#performStatus").val("");
                        $("#sampleStatus").val("");

                        $("#pathologyStatusDiv").addClass("hide");
                        $("#pathologyStatus").val("");
                        // $('input[name="entryType"]').attr("disabled",false);
                        // $('input[name="entryType"][value="0"]').prop("checked","checked");
                    } else if (type == pathologyNum) {
                        $("#standingDiv").addClass("hide");
                        $("#geiyaoDiv").addClass("hide");
                        $("#standing").val("all");
                        $("#geiyaoWays").val("all");

                        $('#medicineDiv').hide();
                        $('#entryTypeDiv').css('display', 'block');
                        $('#medicine').val('all');
                        $("#btnBatch").addClass("hide");
                        $("#performStatusDiv").addClass("hide");
                        $("#sampleStatusDiv").addClass("hide");
                        $("#bloodStatusDiv").addClass("hide");
                        $("#performStatus").val("");
                        $("#sampleStatus").val("");

                        $("#pathologyStatusDiv").removeClass("hide");
                        $("#pathologyStatus").val("");
                    }
                    // if(type == '0'){
                    //     $("#btnExport").css('display','inline-block');
                    // }else{
                    //     $("#btnExport").css('display','none');
                    // }

                    $("#btnQuery").trigger("click");
                });
            },
            //打印
            print: function () {
                $("#btnPrint").click(function () {
                    var strStartTime = $('#startTime').val();
                    var strEndTime = $('#endTime').val();
                    var state = $("#state").val();
                    if (state == "3") {//出院病人全选按钮禁用
                        var time_diff = new Date(strEndTime) - new Date(strStartTime);
                        var days = Math.floor(time_diff / (24 * 3600 * 1000));
                        if (days > 31) {
                            layer.alert("时间范围只能选择一个月！");
                            $('#startTime').val(startOldTime);
                            $('#endTime').val(endOldTime);
                            return;
                        } else {
                            startOldTime = $('#startTime').val();
                            endOldTime = $('#endTime').val();
                        }
                    }
                    var _startTime = new Date(strStartTime).Format("yyyy-MM-dd hh:mm:00");
                    var _endTime = new Date(strEndTime).Format("yyyy-MM-dd hh:mm:59");


                    var wardCode = $('#sel_ward').val();
                    var num = $('#num').text();
                    var showType = $('#showType').text();
                    var medicineType = $('#medicine').val();
                    var geiyaoType = $('#geiyaoWays').val();                     //给药方式
                    var patientNum = $("#patientNum").text();
                    var entryTime = $("#hdEntryTime").val();
                    var inpatientIds = new Array();
                    var supplyCode = new Array();
                    order_type = $('#orderType').val();
                    var entryType = undefined;
                    if (order_type == "0") {
                        entryType = $('#entryType').val();
                    }
                    var performStatus = $("#performStatus").val();
                    var sampleStatus = $("#sampleStatus").val();
                    var bloodStatus = $("#bloodStatus").val();
                    var standingType = $("#standing").val();
                    var pathologyStatus = $("#pathologyStatus").val();



                    var _args = {
                        startTime: _startTime,
                        endTime: _endTime,
                        orderType: order_type,
                        performStatus: performStatus,
                        sampleStatus: sampleStatus,
                        bloodStatus: bloodStatus,
                        pathologyStatus: pathologyStatus,
                        showType: showType,
                        entryType: entryType,
                        patientNum: patientNum,
                        entryTime: entryTime,
                        standing: standingType,
                        geiyaoWay: geiyaoType
                    };
                    var inpatientIds = new Array();
                    if ($('#pageFlag').val() == 'performOperate') {
                        var inpatientId = getInpatientId();
                        if (!isNotEmpty(inpatientId)) {
                            inpatientId = $("#inpatientId").val();
                        }
                        inpatientIds.push(inpatientId);
                        var obj = {
                            inpatientIds: JSON.stringify(inpatientIds),
                        };
                        _args = $.extend({}, _args, obj);
                    } else {
                        $.each($('#patientTable tbody tr:visible input[name="patient"]:checked'), function () {
                            inpatientIds.push($(this).val());
                        });
                        if (inpatientIds.length != 0) {
                            var obj = {
                                inpatientIds: JSON.stringify(inpatientIds),
                            };
                            _args = $.extend({}, _args, obj);
                        }
                    }
                    if (order_type == "2") {
                        var obj = {
                            orderCategory: "5",
                        };
                        _args = $.extend({}, _args, obj);
                    }
                    var tokens = getCookie("token");
                    if (tokens != undefined && tokens != null & tokens != "") {
                        var obj = { token: tokens };
                        _args = $.extend({}, _args, obj);
                    }

                    //多选给药方式
                    var gyfslist = new Array();
                    $('#mutipleDiv ul input:checkbox:checked').each(function () {
                        gyfslist.push($(this).val());//向数组中添加元素
                    });

                    if (gyfslist.length > 0) {
                        _args = $.extend({}, _args, { supplyCodes: gyfslist });
                    }

                    //根据与预执行计划查找医嘱
                    if ($("#cb_istom").prop("checked")) {
                        _args = $.extend({}, _args, { judgeFlag: "tom" });
                    }

                    // _args.judgeFlag = '2';
                    //  _args.isIds = 'y';
                    //  _args.isPatientNum='y';
                    try {
                        $.ajax({
                            url: '/common/template/patrolcard/printList',
                            type: 'POST',
                            async: false,
                            contentType: "application/json;charset=utf-8",
                            data: JSON.stringify(_args),
                        }).done(function (data) {
                            var result = JSON.parse(data).result;
                            var title = "";
                            if ($('#pageFlag').val() == 'performOperate') {
                                title = "药物执行明细";
                            } else {
                                title = "护理执行单";
                            }

                            var checkedformScheduleIdslist = $(".checkedRow").find(".cssperformScheduleIds").map(function () { return $(this).text(); }).get();
                            var pageHead = "<div ><table style='width: 98%;margin: 0 auto;'>" +
                                "<tr><td style='height: 16px; font-weight: bold!important; text-align: center; font-size: 22px!important;' id='page-title'>" + title + "</td></tr>" +
                                "</table></div>";
                            var _html = "";
                            var myDate = new Date();
                            //var nowtime= myDate.toLocaleDateString();
                            var nowtime = new Date().Format("yyyy-MM-dd hh:mm:ss");

                            var wardname = $("#sel_ward").find("option:selected").text();
                            _html += "<table><tr><td>";

                            var jytitle = "加液时间";
                            if ($("#medicine").val() == "kfy" || $("#geiyaoWays").val() == "51" || $("#orderType").val() == "2" || $("#口服51").prop("checked")) {
                                jytitle = "执行时间";
                            }

                            LODOP.PRINT_INIT("");
                            for (let i = 0; i < result.length; i++) {
                                let tableContent = `
                                    <table cellspacing="0" cellpadding="0">
                                        <thead>
                                            <tr>
                                                <td colspan="8" align="center" style="font-size:22px;font-weight:bold">${title}</td>
                                            </tr>
                                            <tr >
                                                <td colspan="8" align="left">姓名:<span class="contentTxt">${result[i][0].name}</span>
                                                床号:<span class="contentTxt">${result[i][0].bedNum == undefined ? "" : result[i][0].bedNum}</span>
                                                年龄:<span class="contentTxt">${result[i][0].age}</span>
                                                病历号:<span class="contentTxt">${result[i][0].patientNum}</span>
                                                病区:<span class="contentTxt">${wardname}</span>
                                                </td>
                                            </tr>
                                                <tr class="tableBox">
                                                    <td style="width: 40%;" align="center" rowspan="3">药品</td>
                                                    <td style="width: 5%" align="center" rowspan="3">用法</td>
                                                    <td style="width: 5%" align="center" rowspan="3">频率</td>
                                                    <td style="width: 10%" align="center" rowspan="3">开单时间</td>
                                                    <td style="width: 8%" align="center" rowspan="3">开单医生</td>
                                                    <td style="width: 5%" align="center" rowspan="3">剂量</td>
                                                    <td style="width: 27%;vertical-align: middle;ext-align:center;" colspan="2">执行情况</td>

                                                </tr>
                                                <tr class="tableBox"><td colspan="2" style="vertical-align: middle;ext-align:center;"> 日期:${nowtime}</td></tr>
                                                    <tr style="" class="tableBox"><td >${jytitle}</td><td>护士签名</td></tr>
                                        </thead>
                                            <tbody class="tableBox">`
                                for (let j in result[i]) {
                                    //console.log(result[i][j])
                                    if(typeof result[i][j]=='function'){continue}
                                    var orderName = result[i][j].orderName;
                                    if ($("#orderType").val() == "2") {
                                        orderName = orderName.replace("1.0000", "");
                                    } else {
                                        orderName = result[i][j].orderName2;
                                    }

                                    if (checkedformScheduleIdslist.length > 0) {
                                        $.each(checkedformScheduleIdslist, function (o, n) {
                                            if (n == result[i][j].performScheduleIds) {
                                                tableContent += `<tr>
                                                        <td align="center">${orderName}</td>
                                                        <td align="center">${result[i][j].supplyName}</td>
                                                        <td align="center">${result[i][j].frequency}</td>
                                                        <td align="center">${result[i][j].makeTime ? result[i][j].makeTime : ''}</td>
                                                        <td>${result[i][j].makeDoctor ? result[i][j].makeDoctor : ''}</td>
                                                        <td>${(result[i][j].dose && result[i][j].doseUnit) ? result[i][j].dose + result[i][j].doseUnit : ''}</td>
                                                        <td></td>
                                                        <td></td>
                                                    </tr>`;
                                            }
                                        });

                                    } else {
                                        tableContent += `<tr>
                                                <td align="center">${orderName}</td>
                                                <td align="center">${result[i][j].supplyName}</td>
                                                <td align="center">${result[i][j].frequency}</td>
                                                <td align="center">${result[i][j].makeTime ? result[i][j].makeTime : ''}</td>
                                                <td>${result[i][j].makeDoctor ? result[i][j].makeDoctor : ''}</td>
                                                <td>${(result[i][j].dose && result[i][j].doseUnit) ? result[i][j].dose + result[i][j].doseUnit : ''}</td>
                                                <td></td>
                                                <td></td>
                                            </tr>`;
                                    }
                                }
                                tableContent += `        </tbody>
                                        </table>`
                                LODOP.ADD_PRINT_TABLE(i==0?"5%":10, i==0?"1%":0, "98%", "80%", ` <style>

                                    .tableBox th,
                                    .tableBox td {
                                        border: 1px solid #000000;
                                    }

                                    table {
                                        width: 100%;
                                        text-align: center;
                                        border-collapse: collapse;
                                        font-size:11px;
                                    }
                                    .contentTxt{
                                        display:inline-block;
                                        min-width: 60px;
                                    }
                                     </style>`+ tableContent)
                                LODOP.SET_PRINT_STYLEA(0, "LinkedItem", i);
                            }

                            //页脚
                            LODOP.ADD_PRINT_TEXT("99%", "48%", 300, 12, "第#页/共&页");
                            LODOP.SET_PRINT_STYLEA(0, "ItemType", 2);
                            LODOP.SET_PRINT_MODE("RESELECT_ORIENT", true);
                            LODOP.PREVIEW();
                            //   LODOP.PRINT_DESIGN();
                        }).fail(function (xhr) {
                            console.log(xhr);
                        });
                    } catch (e) {
                        layer.error(NON_SETUP_PRINT_MESSAGE, e);
                    }
                    $("#printDetailDiv").empty();
                });
            },
            //打印
            print2: function () {
                $("#btnPrint2").click(function () {
                    var strStartTime = $('#startTime').val();
                    var strEndTime = $('#endTime').val();
                    var state = $("#state").val();
                    if (state == "3") {//出院病人全选按钮禁用
                        var time_diff = new Date(strEndTime) - new Date(strStartTime);
                        var days = Math.floor(time_diff / (24 * 3600 * 1000));
                        if (days > 31) {
                            layer.alert("时间范围只能选择一个月！");
                            $('#startTime').val(startOldTime);
                            $('#endTime').val(endOldTime);
                            return;
                        } else {
                            startOldTime = $('#startTime').val();
                            endOldTime = $('#endTime').val();
                        }
                    }
                    var _startTime = new Date(strStartTime).Format("yyyy-MM-dd hh:mm:00");
                    var _endTime = new Date(strEndTime).Format("yyyy-MM-dd hh:mm:59");


                    var wardCode = $('#sel_ward').val();
                    var num = $('#num').text();
                    var showType = $('#showType').text();
                    var medicineType = $('#medicine').val();
                    var geiyaoType = $('#geiyaoWays').val();                     //给药方式
                    var patientNum = $("#patientNum").text();
                    var entryTime = $("#hdEntryTime").val();
                    var inpatientIds = new Array();
                    var supplyCode = new Array();
                    order_type = $('#orderType').val();
                    var entryType = undefined;
                    if (order_type == "0") {
                        entryType = $('#entryType').val();
                    }
                    var performStatus = $("#performStatus").val();
                    var sampleStatus = $("#sampleStatus").val();
                    var bloodStatus = $("#bloodStatus").val();
                    var standingType = $("#standing").val();
                    var pathologyStatus = $("#pathologyStatus").val();



                    var _args = {
                        startTime: _startTime,
                        endTime: _endTime,
                        orderType: order_type,
                        performStatus: performStatus,
                        sampleStatus: sampleStatus,
                        bloodStatus: bloodStatus,
                        pathologyStatus: pathologyStatus,
                        showType: showType,
                        entryType: entryType,
                        patientNum: patientNum,
                        entryTime: entryTime,
                        standing: standingType,
                        geiyaoWay: geiyaoType
                    };
                    var inpatientIds = new Array();
                    if ($('#pageFlag').val() == 'performOperate') {
                        var inpatientId = getInpatientId();
                        if (!isNotEmpty(inpatientId)) {
                            inpatientId = $("#inpatientId").val();
                        }
                        inpatientIds.push(inpatientId);
                        var obj = {
                            inpatientIds: JSON.stringify(inpatientIds),
                        };
                        _args = $.extend({}, _args, obj);
                    } else {
                        $.each($('#patientTable tbody tr:visible input[name="patient"]:checked'), function () {
                            inpatientIds.push($(this).val());
                        });
                        if (inpatientIds.length != 0) {
                            var obj = {
                                inpatientIds: JSON.stringify(inpatientIds),
                            };
                            _args = $.extend({}, _args, obj);
                        }
                    }
                    if (order_type == "2") {
                        var obj = {
                            orderCategory: "5",
                        };
                        _args = $.extend({}, _args, obj);
                    }
                    var tokens = getCookie("token");
                    if (tokens != undefined && tokens != null & tokens != "") {
                        var obj = { token: tokens };
                        _args = $.extend({}, _args, obj);
                    }


                    //多选给药方式
                    var gyfslist = new Array();
                    $('#mutipleDiv ul input:checkbox:checked').each(function () {
                        gyfslist.push($(this).val());//向数组中添加元素
                    });

                    if (gyfslist.length > 0) {
                        _args = $.extend({}, _args, { supplyCodes: gyfslist });
                    }
                    // _args.judgeFlag = '2';
                    //  _args.isIds = 'y';
                    //  _args.isPatientNum='y';
                    try {
                        $.ajax({
                            url: '/common/template/patrolcard/printList',
                            type: 'POST',
                            async: false,
                            contentType: "application/json;charset=utf-8",
                            data: JSON.stringify(_args),
                        }).done(function (data) {
                            var result = JSON.parse(data).result;
                            var title = "";
                            if ($('#pageFlag').val() == 'performOperate') {
                                title = "药物执行明细";
                            } else {
                                title = "输液执行单";
                            }
                            var checkedformScheduleIdslist = $(".checkedRow").find(".cssperformScheduleIds").map(function () { return $(this).text(); }).get();
                            /*               var data = window.localStorage.getItem('hospitalLogoA');
                                          var logoHtml = "<div ><table  style='width: 80%;margin: 0 auto;'><tr><td colspan='4' style='height: 60px;'><img src='"+data+"' alt=''  /></td></tr>";
                                          if(data==null ||data==''||data == undefined){
                                            var hospitalNameLong = window.localStorage.getItem('hospitalNameLong');
                                            logoHtml = "<div ><table style='width: 98%;height:60px;margin: 0 auto;text-align: center;'><tr><td colspan='4' style='height: 50px;'><span style='display:block;font-size:30px;font-weight:bold;'>"+hospitalNameLong+"</span></td></tr>";
                                          }
                                          var pageHead = logoHtml+
                                              "<tr><td colspan='4' style='height: 16px; font-weight: bold!important; text-align: center; font-size: 22px!important;' id='page-title'>"+title+"</td></tr>"+
                                              "</table></div>"; */

                            var pageHead = "<div ><table style='width: 98%;margin: 0 auto;'>" +
                                "<tr><td style='height: 16px; font-weight: bold!important; text-align: center; font-size: 22px!important;' id='page-title'>" + title + "</td></tr>" +
                                "</table></div>";
                            var _html = "";
                            var myDate = new Date();
                            //var nowtime= myDate.toLocaleDateString();
                            var nowtime = new Date().Format("yyyy-MM-dd hh:mm:ss");

                            var wardname = $("#sel_ward").find("option:selected").text();

                            var jytitle = "加液时间";
                            if ($("#medicine").val() == "kfy" || $("#geiyaoWays").val() == "51" || $("#orderType").val() == "2" || $("#口服51").prop("checked")) {
                                jytitle = "执行时间";
                            }



                            LODOP.PRINT_INIT("");
                            for (let i = 0; i < result.length; i++) {
                                let tableContent = `
                                    <table cellspacing="0" cellpadding="0">
                                        <thead>
                                            <tr>
                                                <td colspan="8" align="center" style="font-size:22px;font-weight:bold">${title}</td>
                                            </tr>
                                            <tr >
                                                <td colspan="8" align="left">姓名:<span class="contentTxt">${result[i][0].name}</span>
                                                床号:<span class="contentTxt">${result[i][0].bedNum == undefined ? "" : result[i][0].bedNum}</span>
                                                年龄:<span class="contentTxt">${result[i][0].age}</span>
                                                病历号:<span class="contentTxt">${result[i][0].patientNum}</span>
                                                病区:<span class="contentTxt">${wardname}</span>
                                                </td>
                                            </tr>
                                                <tr class="tableBox">
                                                    <td style="width: 40%;" align="center" rowspan="3">药品</td>
                                                    <td style="width: 5%" align="center" rowspan="3">用法</td>
                                                    <td style="width: 5%" align="center" rowspan="3">频率</td>
                                                    <td style="width: 10%" align="center" rowspan="3">开单时间</td>
                                                    <td style="width: 8%" align="center" rowspan="3">开单医生</td>
                                                    <td style="width: 5%" align="center" rowspan="3">剂量</td>
                                                    <td style="width: 27%;vertical-align: middle;ext-align:center;" colspan="2">执行情况</td>

                                                </tr>
                                                <tr class="tableBox"><td colspan="2" style="vertical-align: middle;ext-align:center;"> 日期:${nowtime}</td></tr>
                                                    <tr style="" class="tableBox"><td >${jytitle}</td><td>护士签名</td></tr>
                                        </thead>
                                            <tbody class="tableBox">`
                                for (let j in result[i]) {
                                    //console.log(result[i][j])
                                    if(typeof result[i][j]=='function'){continue}
                                    var orderName = result[i][j].orderName;
                                    if ($("#orderType").val() == "2") {
                                        orderName = orderName.replace("1.0000", "");
                                    } else {
                                        orderName = result[i][j].orderName2;
                                    }

                                    if (checkedformScheduleIdslist.length > 0) {
                                        $.each(checkedformScheduleIdslist, function (o, n) {
                                            if (n == result[i][j].performScheduleIds) {
                                                var yy = 1;
                                                if (result[i][j].standingOrder == '0') {
                                                    yy = 0;
                                                    /*                                                         var makeTime = result[i][j].makeTime ? result[i][j].makeTime : '';
                                                                                                            //判断是否今天
                                                                                                            if (makeTime == "") { yy = 0; }
                                                                                                            else {
                                                                                                                if (isToday(makeTime)) {
                                                                                                                    var yy2 = 0;
                                                                                                                    for (var j1 = 0; j1 < result[i].length; j1++) {

                                                                                                                        var n1 = result[i][j1].orderName;
                                                                                                                        var n2 = result[i][j].orderName;
                                                                                                                        if (result[i][j1].standingOrder == "1" && n1 == n2) {
                                                                                                                            yy2 = 1;
                                                                                                                            break;
                                                                                                                        }
                                                                                                                    }
                                                                                                                    if (yy2 != 1) { yy = 0; }
                                                                                                                }
                                                                                                            }
                                                                                                            yy = 0; */
                                                }
                                                else if (yy == 1 && result[i][j].hasOwnProperty('end_time')) {
                                                    var end_time = result[i][j].end_time;
                                                    //更改获取时间的类型
                                                    var datetime = new Date(Date.parse(end_time.replace(/-/g, "/")));
                                                    //获取明天
                                                    var day3 = new Date();
                                                    day3.setTime(day3.getTime() + 24 * 60 * 60 * 1000);
                                                    var s3 = day3.getFullYear() + "-" + (day3.getMonth() + 1) + "-" + day3.getDate();
                                                    //判断两个时间段
                                                    if (new Date(Date.parse(end_time.replace(/-/g, "/"))) < new Date(Date.parse(s3.replace(/-/g, "/")))) {
                                                        yy = 0;
                                                    }
                                                }
                                                if (yy == 1) {
                                                    tableContent += `<tr>
                                                        <td align="center">${orderName}</td>
                                                        <td align="center">${result[i][j].supplyName}</td>
                                                        <td align="center">${result[i][j].frequency}</td>
                                                        <td align="center">${result[i][j].makeTime ? result[i][j].makeTime : ''}</td>
                                                        <td>${result[i][j].makeDoctor ? result[i][j].makeDoctor : ''}</td>
                                                        <td>${(result[i][j].dose && result[i][j].doseUnit) ? result[i][j].dose + result[i][j].doseUnit : ''}</td>
                                                        <td></td>
                                                        <td></td>
                                                    </tr>`;
                                                }
                                            }
                                        });

                                    } else {

                                        var yy = 1;
                                        if (result[i][j].standingOrder == '0') {
                                            yy = 0;
                                            /*                                                 var makeTime = result[i][j].makeTime ? result[i][j].makeTime : '';
                                                                                            //判断是否今天
                                                                                            if (makeTime == "") { yy = 0; }
                                                                                            else {
                                                                                                if (isToday(makeTime)) {
                                                                                                    var yy2 = 0;
                                                                                                    for (var j1 = 0; j1 < result[i].length; j1++) {

                                                                                                        var n1 = result[i][j1].orderName;
                                                                                                        var n2 = result[i][j].orderName;
                                                                                                        if (result[i][j1].standingOrder == "1" && n1 == n2) {
                                                                                                            yy2 = 1;
                                                                                                            break;
                                                                                                        }
                                                                                                    }
                                                                                                    if (yy2 != 1) { yy = 0; }
                                                                                                }
                                                                                            } */
                                        }
                                        else if (result[i][j].hasOwnProperty('end_time')) {
                                            var end_time = result[i][j].end_time;
                                            //更改获取时间的类型
                                            var datetime = new Date(Date.parse(end_time.replace(/-/g, "/")));
                                            //获取明天
                                            var day3 = new Date();
                                            day3.setTime(day3.getTime() + 24 * 60 * 60 * 1000);
                                            var s3 = day3.getFullYear() + "-" + (day3.getMonth() + 1) + "-" + day3.getDate();
                                            //判断两个时间段
                                            if (new Date(Date.parse(end_time.replace(/-/g, "/"))) < new Date(Date.parse(s3.replace(/-/g, "/")))) {
                                                yy = 0;
                                            }
                                        }
                                        if (yy == 1) {
                                            tableContent += `<tr>
                                                <td align="center">${orderName}</td>
                                                <td align="center">${result[i][j].supplyName}</td>
                                                <td align="center">${result[i][j].frequency}</td>
                                                <td align="center">${result[i][j].makeTime ? result[i][j].makeTime : ''}</td>
                                                <td>${result[i][j].makeDoctor ? result[i][j].makeDoctor : ''}</td>
                                                <td>${(result[i][j].dose && result[i][j].doseUnit) ? result[i][j].dose + result[i][j].doseUnit : ''}</td>
                                                <td></td>
                                                <td></td>
                                            </tr>`;
                                        }

                                    }
                                }
                                tableContent += `        </tbody>
                                        </table>`
                                LODOP.ADD_PRINT_TABLE(i==0?"5%":10, i==0?"1%":0, "98%", "80%", ` <style>

                                    .tableBox th,
                                    .tableBox td {
                                        border: 1px solid #000000;
                                    }

                                    table {
                                        width: 100%;
                                        text-align: center;
                                        border-collapse: collapse;
                                        font-size:11px;
                                    }
                                    .contentTxt{
                                        display:inline-block;
                                        min-width: 60px;
                                    }
                                     </style>`+ tableContent)
                                LODOP.SET_PRINT_STYLEA(0, "LinkedItem", i);
                            }
                            //页脚
                            LODOP.ADD_PRINT_TEXT("99%", "48%", 300, 12, "第#页/共&页");
                            LODOP.SET_PRINT_STYLEA(0, "ItemType", 2);
                            LODOP.SET_PRINT_MODE("RESELECT_ORIENT", true);
                            LODOP.PREVIEW();

                            /*  _html += "<table><tr><td>";
                             for (var i = 0; i < result.length; i++) {
                                 var _table = "<table><tr><td>";
                                 _table += pageHead + `<table style="table-layout: fixed;width: 98%;font-size:20px;"><tr>
             <td>
             <span style="margin-right:20px;">姓名:${result[i][0].name}</span>
             <span style="margin-right:20px;">床号:${result[i][0].bedNum == undefined ? "" : result[i][0].bedNum}</span>
             <span style="margin-right:20px;">年龄:${result[i][0].age}</span>
             <span style="margin-right:20px;">病历号:${result[i][0].patientNum}</span>
             <span style="margin-right:20px;">病区:${wardname}</span>
             </td></tr></table>
<table style="table-layout: fixed;width: 98%;" cellspacing="0" cellpadding="0" border="1" class="jsgrid-table">
<thead>
<tr>
<th style="width: 40%;" align="center" rowspan="3">药品</th>
<th style="width: 5%" align="center" rowspan="3">用法</th>
<th style="width: 5%" align="center" rowspan="3">频率</th>
<th style="width: 8%" align="center" rowspan="3">开单时间</th>
<th style="width: 8%" align="center" rowspan="3">开单医生</th>
<th style="width: 5%" align="center" rowspan="3">剂量</th>
<th style="width: 29%;vertical-align: middle;ext-align:center;height:16px;" colspan="2">执行情况</th>
</tr>
<tr><th colspan="2" style="vertical-align: middle;ext-align:center;height:16px;"> 日期:${nowtime}</th></tr>
<tr style="height:16px;"><th >${jytitle}</th><th>护士签名</th></tr>
</thead><tbody>`;

                                 var _tr = "";
                                 for (var j = 0; j < result[i].length; j++) {
                                     var orderName = result[i][j].orderName;
                                     if ($("#orderType").val() == "2") {
                                         orderName = orderName.replace("1.0000", "");
                                     } else {
                                         orderName = result[i][j].orderName2;
                                     }

                                     if (checkedformScheduleIdslist.length > 0) {
                                         $.each(checkedformScheduleIdslist, function (o, n) {
                                             if (n == result[i][j].performScheduleIds) {
                                                 var yy = 1;
                                                 if (result[i][j].standingOrder == '0') {
                                                     var makeTime = result[i][j].makeTime ? result[i][j].makeTime : '';
                                                     //判断是否今天
                                                     if (makeTime == "") { yy = 0; }
                                                     else {
                                                         if (isToday(makeTime)) {
                                                             var yy2 = 0;
                                                             for (var j1 = 0; j1 < result[i].length; j1++) {

                                                                 var n1 = result[i][j1].orderName;
                                                                 var n2 = result[i][j].orderName;
                                                                 if (result[i][j1].standingOrder == "1" && n1 == n2) {
                                                                     yy2 = 1;
                                                                     break;
                                                                 }
                                                             }
                                                             if (yy2 != 1) { yy = 0; }
                                                         }
                                                     }
                                                     yy = 0;
                                                 }
                                                 else if (yy == 1 && result[i][j].hasOwnProperty('end_time')) {
                                                     var end_time = result[i][j].end_time;
                                                     //更改获取时间的类型
                                                     var datetime = new Date(Date.parse(end_time.replace(/-/g, "/")));
                                                     //获取明天
                                                     var day3 = new Date();
                                                     day3.setTime(day3.getTime() + 24 * 60 * 60 * 1000);
                                                     var s3 = day3.getFullYear() + "-" + (day3.getMonth() + 1) + "-" + day3.getDate();
                                                     //判断两个时间段
                                                     if (new Date(Date.parse(end_time.replace(/-/g, "/"))) < new Date(Date.parse(s3.replace(/-/g, "/")))) {
                                                         yy = 0;
                                                     }
                                                 }
                                                 if (yy == 1) {

                                                     _tr += `<tr>
                                                                             <td align="center">${orderName}</td>
                                                                             <td align="center">${result[i][j].supplyName}</td>
                                                                             <td align="center">${result[i][j].frequency}</td>
                                                                             <td align="center">${result[i][j].makeTime ? result[i][j].makeTime : ''}</td>
                                                                             <td>${result[i][j].makeDoctor ? result[i][j].makeDoctor : ''}</td>
                                                                             <td>${(result[i][j].dose && result[i][j].doseUnit) ? result[i][j].dose + result[i][j].doseUnit : ''}</td>
                                                                             <td></td>
                                                                             <td></td>
                                                                               </tr>`;

                                                 }
                                             }
                                         });

                                     } else {

                                         var yy = 1;
                                         if (result[i][j].standingOrder == '0') {
                                             var makeTime = result[i][j].makeTime ? result[i][j].makeTime : '';
                                             //判断是否今天
                                             if (makeTime == "") { yy = 0; }
                                             else {
                                                 if (isToday(makeTime)) {
                                                     var yy2 = 0;
                                                     for (var j1 = 0; j1 < result[i].length; j1++) {

                                                         var n1 = result[i][j1].orderName;
                                                         var n2 = result[i][j].orderName;
                                                         if (result[i][j1].standingOrder == "1" && n1 == n2) {
                                                             yy2 = 1;
                                                             break;
                                                         }
                                                     }
                                                     if (yy2 != 1) { yy = 0; }
                                                 }
                                             }
                                         }
                                         else if (result[i][j].hasOwnProperty('end_time')) {
                                             var end_time = result[i][j].end_time;
                                             //更改获取时间的类型
                                             var datetime = new Date(Date.parse(end_time.replace(/-/g, "/")));
                                             //获取明天
                                             var day3 = new Date();
                                             day3.setTime(day3.getTime() + 24 * 60 * 60 * 1000);
                                             var s3 = day3.getFullYear() + "-" + (day3.getMonth() + 1) + "-" + day3.getDate();
                                             //判断两个时间段
                                             if (new Date(Date.parse(end_time.replace(/-/g, "/"))) < new Date(Date.parse(s3.replace(/-/g, "/")))) {
                                                 yy = 0;
                                             }
                                         }
                                         if (yy == 1) {


                                             _tr += `<tr>
                                                 <td align="center">${orderName}</td>
                                                 <td align="center">${result[i][j].supplyName}</td>
                                                 <td align="center">${result[i][j].frequency}</td>
                                                 <td align="center">${result[i][j].makeTime ? result[i][j].makeTime : ''}</td>
                                                 <td>${result[i][j].makeDoctor ? result[i][j].makeDoctor : ''}</td>
                                                 <td>${(result[i][j].dose && result[i][j].doseUnit) ? result[i][j].dose + result[i][j].doseUnit : ''}</td>
                                                 <td></td>
                                                 <td></td>
                                                   </tr>`;
                                         }
                                     }
                                 }
                                 _table += _tr + "</tbody></table>";
                                 _table += `</td></tr></table>`;
                                 if (_tr != "") { _html += _table; }
                             }
                             _html += `</td></tr></table>`;

                             LODOP.PRINT_INIT("");
                             var strStyle = $($("#hideHtml input[name='hidePrintHtml']")[0]).val();
                             LODOP.SET_PRINT_STYLEA(0, "ItemType", 1);
                             LODOP.ADD_PRINT_HTM("5%", 9, "98%", "90%", strStyle + _html);
                             //LODOP.ADD_PRINT_TABLE("5%", 9, "98%", "80%", strStyle + _html);

                             //页脚
                             LODOP.ADD_PRINT_TEXT("99%", "48%", 300, 12, "第#页/共&页");
                             LODOP.SET_PRINT_STYLEA(0, "ItemType", 2);
                             LODOP.SET_PRINT_MODE("RESELECT_ORIENT", true);
                             LODOP.PREVIEW(); */
                        }).fail(function (xhr) {
                            console.log(xhr);
                        });
                    } catch (e) {
                        layer.error(NON_SETUP_PRINT_MESSAGE, e);
                    }
                    $("#printDetailDiv").empty();
                });
            },
            //打印
            print3: function () {
                $("#btnPrint").click(function () {
                    try {
                        // $('#advice-content .jsgrid-grid-body tbody').prepend($('#advice-content .jsgrid-grid-header .jsgrid-header-row'));

                        var checkboxs = $("input[name='geiyaoWays']:checked");
                        var _checkedIds = new Array();                                                  //    抓取被勾选的复选框的流水id
                        $.each(checkboxs, function (index, el) {
                            if ($(el).is(':checked')) {
                                _checkedIds.push($(el).attr('incrementId'));
                            }
                        });


                        var printinner = $("#advice-content").clone()
                        var tr = new Array();
                        tr = printinner.find('.jsgrid-grid-body tbody').find('tr');
                        if (_checkedIds.length > 0) {
                            var ids = _checkedIds.toString();                                          //       对照流水id来选择打印
                            $.each(tr, function (q, n) {
                                var incrementIdss = $(n).find("input[name='geiyaoWays']").attr('incrementId');
                                if (ids.indexOf(incrementIdss) == -1) {
                                    tr[q].remove();
                                }
                            });
                        }


                        printinner.find('.jsgrid-grid-body tbody').prepend(printinner.find('.jsgrid-grid-header .jsgrid-header-row'));
                        LODOP.PRINT_INIT("");
                        var strStyle = "<link href='/css/nurse/patrolCard/print.css' type='text/css' rel='stylesheet'>";
                        $(".printHead").removeClass("hide");
                        $("#gridList").find(".hide").remove();
                        var title = "";
                        if ($('#pageFlag').val() == 'performOperate') {
                            title = "药物执行明细";
                        } else {
                            title = "巡视卡";
                        }
                        var date = "日期：" + $('#startTime').val() + " ~ " + $('#endTime').val();
                        $('#date').text(date);
                        var _html = printinner.html();


                        var data = window.localStorage.getItem('hospitalLogoA');
                        var logoHtml = "<div ><table style='width: 80%;margin: 0 auto;'><tr><td colspan='4' style='height: 60px;'><img src='" + data + "' alt=''  /></td></tr>";
                        if (data == null || data == '' || data == undefined) {
                            var hospitalNameLong = window.localStorage.getItem('hospitalNameLong');
                            logoHtml = "<div ><table style='width: 98%;height:60px;margin: 0 auto;text-align: center;'><tr><td colspan='4' style='height: 50px;'><span style='display:block;font-size:30px;font-weight:bold;'>" + hospitalNameLong + "</span></td></tr>";
                        }
                        var pageHead = logoHtml +
                            "<tr><td colspan='4' style='height: 16px; font-weight: bold!important; text-align: center; font-size: 22px!important;' id='page-title'>" + title + "</td></tr>" +
                            "</table></div>";
                        LODOP.SET_PRINT_PAGESIZE(1, "210mm", "297mm", "");
                        //页眉
                        LODOP.ADD_PRINT_HTM(0, "7%", "98%", 145, pageHead);
                        LODOP.SET_PRINT_STYLEA(0, "ItemType", 1);
                        LODOP.ADD_PRINT_HTM("11%", 9, "98%", "85%", strStyle + _html);
                        //页脚
                        LODOP.ADD_PRINT_TEXT("99%", "48%", 300, 12, "第#页/共&页");
                        LODOP.SET_PRINT_STYLEA(0, "ItemType", 2);
                        LODOP.PREVIEW();
                        //$('#btnQuery').trigger('click');
                        $(".printHead").addClass("hide");
                    } catch (e) {
                        layer.error(NON_SETUP_PRINT_MESSAGE, e);
                    }
                });
            },
            //分类切换
            changeGroup: function () {
                $('body').on('change', '#selectGroup', function (event) {
                    var group = $('#selectGroup').val();
                    Page.Event.patientInit({ group_no: group });
                    Page.Event.getPatientsCount();
                    $('input[name="allpatient"]').prop("checked", false);
                    $("#btnQuery").trigger("click");
                });
            },
            //执行状态改变
            changeexecutionStatus: function () {
                $('body').on('change', '#performStatus', function (event) {
                    var typeOrder = $('#orderType').val();
                    if (typeOrder == "1") {
                        $("#btnQuery").trigger("click");
                    }
                });
            },
            //病人分组
            getAllWardGroup: function () {
                var wardId = $("#sel_ward").val();
                if (!wardId)
                    return;
                $.ajax({
                    url: '/wardGroup/getGroupByWardId',
                    type: 'GET',
                    contentType: 'application/json;charset=utf-8',
                    data: { 'wardId': wardId }
                }).done(function (res) {
                    if (res.state == 200) {
                        var groupList = res.results.wardGroup;
                        $("#selectGroup").empty();
                        $("#selectGroup").append("<option value=''>整个病区</option>");
                        if (groupList.length > 0) {
                            for (var i = 0; i < groupList.length; i++) {
                                var groupNo = groupList[i].groupNo;
                                $("#selectGroup").append("<option value='" + groupNo + "'>组" + groupNo + "</option>");
                            }
                            $("#selectGroup").append("<option value='no'>未分组</option>");
                        }
                    } else {
                        console.log(JSON.stringify(res));
                    }
                }).fail(function (xhr) {
                    console.log(xhr);
                });
            },
            resizeTableWidth: function () {

                var tTD; //用来存储当前更改宽度的Table Cell,避免快速移动鼠标的问题
                var table = $("#gridList").find(".jsgrid-table").get(0);
                var table1 = $("#gridList").find(".jsgrid-table").get(1);
                for (var j = 0, len = table.rows[0].cells.length; j < len; j++) {
                    table.rows[0].cells[j].onmousedown = function () {
                        //记录单元格
                        tTD = this;
                        if (event.offsetX > tTD.offsetWidth - 10) {
                            tTD.mouseDown = true;
                            tTD.oldX = event.x;
                            tTD.oldWidth = tTD.offsetWidth;
                        }
                    };
                    table.rows[0].cells[j].onmouseup = function () {
                        //结束宽度调整
                        if (tTD == undefined) tTD = this;
                        tTD.mouseDown = false;
                        tTD.style.cursor = 'default';
                    };
                    table.rows[0].cells[j].onmousemove = function () {
                        //更改鼠标样式
                        if (event.offsetX > this.offsetWidth - 10) {
                            this.style.cursor = 'col-resize';
                        } else {
                            this.style.cursor = 'default';
                        }
                        //取出暂存的Table Cell
                        if (tTD == undefined) tTD = this;
                        if (tTD.mouseDown != null && tTD.mouseDown == true) {
                            tTD.style.cursor = 'default';
                            if (tTD.oldWidth + (event.x - tTD.oldX) > 0) {
                                tTD.width = tTD.oldWidth + (event.x - tTD.oldX);
                            }
                            //调整列宽
                            tTD.style.width = tTD.width + "px";
                            tTD.style.cursor = 'col-resize';
                            //调整该列中的每个Cell
                            //table = tTD;
                            //while (table.tagName != 'TABLE') table = table.parentElement;
                            for (var j = 0, len = table1.rows.length; j < len; j++) {
                                table1.rows[j].cells[tTD.cellIndex].style.width = tTD.width + "px";
                            }
                        }
                    };
                }
                $(document).on('mouseup', function () {
                    tTD.mouseDown = "false";
                })
            }
            , ingoway: function () {

                $("#mutipleDiv ul").html("");
                var html = "";
                $.each(gy.geiyaoWays, function (i, n) {
                    if (n.value != "全部") {
                        html += '<li style="width:33%;float:left;"><label style="cursor:pointer;margin-bottom: 0px;"><input type="checkbox" style="vertical-align: -16%;" id="' + n.value + n.code + '" value="' + n.code + '">' + n.value + '</label></li>'
                    }
                });
                $("#mutipleDiv ul").html(html);

                //所属病区显示隐藏
                $('#geiyaoWayslist').on('click', function () {

                    $('#mutipleDiv').show();
                    var tops = $("#geiyaoWayslist").offset().top;
                    var lefts = $("#geiyaoWayslist").offset().left;
                    $("#mutipleDiv").offset({ top: tops + 35, left: lefts });
                })

                $('#default-save').on('click', function () {
                    var str = "";
                    var str1 = "";
                    $('#mutipleDiv input:checked').each(function (index, ele) {
                        str += $(this).parent().text();
                        str = str.trim();
                        str += '、';
                        str1 += $(this).val() + ',';
                    })
                    str = str.slice(0, -1);
                    $('#geiyaoWayslist').val(str);
                    $('#mutipleDiv').hide();
                    $("#btnQuery").trigger("click");
                });
                $('#default-reset').on('click', function () {
                    $('#mutipleDiv input').prop('checked', false);
                })
                $('#default-chooseAll').on('click', function () {
                    $('#mutipleDiv input').prop('checked', true);
                })
            }

        };

        //全选病人列表
        $('input[name="allpatient"]').change(function () {
            if ($('input[name="allpatient"]').prop("checked")) {
                $('input[name="patient"]').prop("checked", true);
            } else {
                $('input[name="patient"]').prop("checked", false);
            }
            $("#btnQuery").trigger("click");
        });
        //病人列表切换
        $("#patientList").delegate($('input[name="patient"]'), "change", function () {
            if (!$(this).prop("checked")) {
                $('input[name="allpatient"]').prop("checked", false);
            }
            if ($('input[name="patient"]').not("input:checked").length == 0) {
                $('input[name="allpatient"]').prop("checked", true);
            }
            $("#btnQuery").trigger("click");
        });

        //病人列表选中行
        $("#patientList").on("click", "tr", function (e) {
            if (e.target.nodeName == "LABEL" || e.target.nodeName == "INPUT") return;
            if ($(this).find("input[name='patient']").prop("checked") == true) {
                $(this).find("input[name='patient']").prop("checked", false);
                $('input[name="allpatient"]').prop("checked", false);
            } else {
                $(this).find("input[name='patient']").prop("checked", true);
            }
            $("#btnQuery").trigger("click");

        });

        //口服药选中样式切换
        $("#medicine").change(function () {
            if ($("#medicine").val() == "kfy" || $("#geiyaoWays").val() == "51" || $("#口服51").prop("checked")) {
                $("#btnBatch").removeClass("hide");
                $("input[name='batchChk']").parent().removeClass("hide");
                $(".jsgrid-header-row").find(".chk").removeClass("hide");
            } else {
                $("input[name='batchChk']").parent().addClass("hide");
                $(".jsgrid-header-row").find(".chk").addClass("hide");
                $("#btnBatch").addClass("hide");
            }
            $("#btnQuery").trigger("click");
        });
        $("#geiyaoWays").change(function () {
            $("#btnQuery").trigger("click");
        });


        //口服药批量处理
        $("#btnBatch").click(function () {
            var batchRecords = new Array();
            if ($("input[name='batchChk']:checked").length < 1) {
                layer.msg("未选择要批量处理的药品", { icon: 0 });
            } else {
                $("input[name='batchChk']:checked").each(function () {
                    var inpatientId = $(this).parent().parent().find("td.cssinpatientId").text();
                    var performScheduleIds = $(this).parent().parent().find("td.cssperformScheduleIds").text();
                    var hisOrderIds = $(this).parent().parent().find("td.csshisOrderIds").text();
                    var standingOrder = $(this).parent().parent().find("td.cssstandingOrder").text();
                    var hisScheduleIds = $(this).parent().parent().find("td.csshisScheduleIds").text();
                    var groupId = $(this).parent().parent().find("td.cssgroupId").text();
                    var schedulePerformTime = $(this).parent().parent().find("td.cssschedulePerformTime").text();
                    var obj = {
                        inpatientId: inpatientId,
                        groupId: groupId,
                        performScheduleIds: performScheduleIds,
                        hisOrderIds: hisOrderIds,
                        hisScheduleIds: hisScheduleIds,
                        schedulePerformTime: new Date(schedulePerformTime).Format("yyyy-MM-dd hh:mm:ss"),
                        standingOrder: standingOrder,
                    };
                    batchRecords.push(JSON.stringify(obj));
                });
                var _batchRecords = batchRecords.join(";");
                if ($.inArray(ROLERIGHT.update, roleRight) < 0) { //判断是否有编辑修改的的权限
                    layer.msg(roleRightTipMsg, { icon: 2 });
                    return;
                }
                layer.open({
                    type: 2,
                    title: '异常处理',
                    shift: '',
                    content: '/patrolcard/exception?order_type=1&batchRecords=' + encodeURI(_batchRecords),
                    area: ['450px', '400px'],
                    success: function () { },
                    zIndex: '200',
                    scrolling: 'no'
                });
            }
        });
        //口服药选中行
        $("#gridList").on("click", ".jsgrid-alt-row, .jsgrid-row", function () {


            if ($("#medicine").val() == "kfy" || $("#geiyaoWays").val() == "51" || $("#口服51").prop("checked")) {
                if ($(this).find("input[name='batchChk']").prop("checked") == true) {
                    $(this).find("input[name='batchChk']").prop("checked", false);
                    $(this).addClass("checkedRow");
                } else {
                    if ($("input[name='batchChk']:checked").length < 5) {
                        $(this).find("input[name='batchChk']").prop("checked", true);
                        $(this).removeClass("checkedRow");
                    } else {
                        layer.msg("最多只能选择5个");
                        $(this).prop("checked", false);
                    }
                }
            }
        });

        //搜索病人
        $('body').on('keyup', '#patient-filter', function (event) {
            var key = $(this).val().trim(); //关键字
            var selector = '';
            selector = '#patientTable tbody tr';
            if (!key) {
                $(selector).show();
                patientSearchedDisplay();
                return;
            }
            $(selector).hide()//先隐藏所有节点
            var patientList = $(selector);
            for (var i = 0; i < patientList.length; i++) {
                var patientName = $(patientList[i]).find(".patient-name").text();
                var bedNum = $(patientList[i]).find(".patient-bedNum").text();
                var isShow = false;
                if (patientName && patientName.indexOf(key) >= 0) {//姓名
                    isShow = true;
                }
                if (bedNum && bedNum.indexOf(key) >= 0) {//床号
                    isShow = true;
                }
                if (isShow) {
                    $(patientList[i]).show();
                }
            }
            patientSearchedDisplay();
            if ($('input[name="patient"]').not("input:checked").length == 0) {
                $('input[name="allpatient"]').prop("checked", true);
            }
        });
        /**没有病人时显示未查询到患者*/
        function patientSearchedDisplay() {
            $('#patientTable').show();
            if ($("#patientTable tbody tr:visible").size() == 0) {
                $(".patient-index-not-found").show();
                $('#patientTable').hide();
            } else {
                $(".patient-index-not-found").hide();
                $('#patientTable').show();
            }
        }
        $('#gridList').on('click', '#handleExc', function () {
            indexId++;
            $(this).parent().parent().attr('id', 'index' + indexId);
            $(this).parent().parent().addClass('blue').siblings().removeClass('blue');

            Page.Event.openTransfusionPage(this, 'index' + indexId);
        });

        $('#gridList').on('click', '.blby', function () {
            indexId++;
            Page.Event.openPathologyPage(this, 'index' + indexId)
        });



        function isToday(date) {
            return formatDate(new Date()) === date.toString().substr(0, 10);
        }
        function formatDate(date) {
            var y = date.getFullYear();
            var m = date.getMonth() + 1;
            m = m < 10 ? '0' + m : m;
            var d = date.getDate();
            d = d < 10 ? ('0' + d) : d;
            return y + '-' + m + '-' + d;
        };

        //拖拽改变表头宽度
        function resizeTableWidth() {
            var tTD; //用来存储当前更改宽度的Table Cell,避免快速移动鼠标的问题
            var table = $("#gridList").find(".jsgrid-table").get(0);
            var table1 = $("#gridList").find(".jsgrid-table").get(1);
            for (var j = 0, len = table.rows[0].cells.length; j < len; j++) {
                table.rows[0].cells[j].onmousedown = function () {
                    //记录单元格
                    tTD = this;
                    console.log(event.clientY)
                    if (event.offsetX > tTD.offsetWidth - 10) {
                        tTD.mouseDown = true;
                        tTD.oldX = event.x;
                        tTD.oldWidth = tTD.offsetWidth;
                    }
                };
                table.rows[0].cells[j].onmousemove = function () {
                    //更改鼠标样式
                    if (event.offsetX > this.offsetWidth - 10) {
                        this.style.cursor = 'e-resize';
                    } else {
                        this.style.cursor = 'default';
                    }
                    //超出此区域禁用此效果
                    if (event.clientY > 150 && event.clientY < 169) {
                        //取出暂存的Table Cell
                        if (tTD == undefined) tTD = this;
                        if (tTD.mouseDown != null && tTD.mouseDown == true) {
                            tTD.style.cursor = 'default';
                            if (tTD.oldWidth + (event.x - tTD.oldX) > 0) {
                                tTD.width = tTD.oldWidth + (event.x - tTD.oldX);
                            }
                            //调整列宽
                            tTD.style.width = tTD.width + "px";
                            tTD.style.cursor = 'e-resize';
                            //调整该列中的每个Cell
                            for (var j = 0, len = table1.rows.length; j < len; j++) {
                                if (table1.rows[j].cells[tTD.cellIndex] != undefined) {
                                    table1.rows[j].cells[tTD.cellIndex].style.width = tTD.width + "px";
                                }

                            }
                        }
                    } else {
                        this.style.cursor = 'default';
                        if (tTD == undefined) {
                            tTD = this;
                        }
                        tTD.mouseDown = false;
                    }
                };
                table.rows[0].cells[j].onmouseup = function () {
                    //结束宽度调整
                    if (tTD == undefined) tTD = this;
                    tTD.mouseDown = false;
                    tTD.style.cursor = 'default';
                };
            }
        }
        Page.Event.init();
    })(jQuery);
</script>
</html>